comparison src/browser.c @ 5515:439a05a6b409

[gaim-migrate @ 5914] This makes the manual browser setting good. -You can have multiple %s's in a browser command (I don't know why you would want to, but you can) -It doesn't double-free memory and cause gaim to crash -If there is no %s, it adds the URL to the end of the command (it did this before, I'm just re-iterating that it still works) -It's fewer lines of code and it's cleaner, I think committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 25 May 2003 18:35:24 +0000
parents d1524728d491
children 7a64114641c3
comparison
equal deleted inserted replaced
5514:5664dbaf670c 5515:439a05a6b409
582 case BROWSER_MOZILLA: 582 case BROWSER_MOZILLA:
583 command = g_strdup_printf("mozilla \"%s\"", url); 583 command = g_strdup_printf("mozilla \"%s\"", url);
584 break; 584 break;
585 585
586 case BROWSER_MANUAL: { 586 case BROWSER_MANUAL: {
587 char *space_free_url = NULL;
588 char *web_tmp = NULL;
589
590 if (!web_command[0]) { 587 if (!web_command[0]) {
591 gaim_notify_error(NULL, NULL, 588 gaim_notify_error(NULL, NULL,
592 _("Unable to launch your browser because " 589 _("Unable to launch your browser because "
593 "the 'Manual' browser command has been " 590 "the 'Manual' browser command has been "
594 "chosen, but no command has been set."), 591 "chosen, but no command has been set."),
595 NULL); 592 NULL);
596 return; 593 return;
597 } 594 }
598 595
599 space_free_url = g_strdup(url);
600 g_strdelimit(space_free_url, " ", '+');
601 /*
602 if (strstr(web_command, "%s")) 596 if (strstr(web_command, "%s"))
603 command = g_strdup_printf(web_command, space_free_url); 597 command = gaim_strreplace(web_command, "%s", url);
604
605 Replaced the above with the following to avoid users
606 from entering more than one %s as part of the browser
607 command.
608 */
609 web_tmp = strstr(web_command, "%s");
610 if(web_tmp)
611 {
612 if (strstr((web_tmp + 1), "%s"))
613 command = g_strdup_printf(web_command, space_free_url);
614 else
615 gaim_notify_error(NULL, NULL, _("Unable to launch your browser because the 'Manual' browser command has too many '%s'."), NULL);
616 }
617 else 598 else
618 command = g_strdup_printf("%s %s", web_command, space_free_url); 599 /* There is no "%s" in the browser command. Assume the user
619 g_free(space_free_url); 600 * wanted the URL tacked on to the end of the command. */
620 g_free(web_tmp); 601 command = g_strdup_printf("%s %s", web_command, url);
621 } break; 602 } break;
622 } 603 }
623 604
624 if (g_spawn_command_line_async(command, &error) == FALSE) { 605 if (g_spawn_command_line_async(command, &error) == FALSE) {
625 char *tmp = g_strdup_printf(_("There was an error launching your chosen browser: %s"), error->message); 606 char *tmp = g_strdup_printf(_("There was an error launching your chosen browser: %s"), error->message);