# HG changeset patch # User Mark Doliner # Date 1092879930 0 # Node ID 8d891252f2aceb21ffaa0d7e00c97f830d3b9f65 # Parent 1e5ef71c9583eaf4c0c48f8ed25ae4bc8244714f [gaim-migrate @ 10645] URLs containing ' will open correctly. There was some over-zealous double-quotation mark usage in gtknotify.c. That may have been my fault. Also escape the URLs in debug and gaim_notify messages. Also refactored gaim_escape_html() a tad bit. There is nothing wrong with exiting out of a function early. In the abnormal case that html==NULL, we just exit the function. It makes the meat of the function nested one fewer level. committer: Tailor Script diff -r 1e5ef71c9583 -r 8d891252f2ac ChangeLog --- a/ChangeLog Thu Aug 19 01:13:58 2004 +0000 +++ b/ChangeLog Thu Aug 19 01:45:30 2004 +0000 @@ -21,6 +21,7 @@ * Better file transfer cancel messages for AIM (Dave West) * Buddy list tooltips display in more appropriate positions when using multiple monitors (Dave West) + * Better parsing of URLs containing special characters version 0.81 (08/05/2004): New Features: diff -r 1e5ef71c9583 -r 8d891252f2ac src/gtknotify.c --- a/src/gtknotify.c Thu Aug 19 01:13:58 2004 +0000 +++ b/src/gtknotify.c Thu Aug 19 01:45:30 2004 +0000 @@ -407,20 +407,18 @@ static gint uri_command(const char *command, gboolean sync) { + gchar *escaped, *tmp; GError *error = NULL; gint ret = 0; - gaim_debug_misc("gtknotify", "Executing %s\n", command); + escaped = gaim_escape_html(command); + gaim_debug_misc("gtknotify", "Executing %s\n", escaped); if (!gaim_program_is_valid(command)) { - gchar *tmp; - - tmp = g_strdup_printf(_("The browser command \"%s\" is invalid."), - command ? command : "(none)"); - + tmp = g_strdup_printf(_("The browser command %s is invalid."), + escaped ? escaped : "(none)"); gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); - g_free(tmp); } @@ -430,11 +428,9 @@ if (!g_spawn_command_line_sync(command, NULL, NULL, &status, &error)) { - char *tmp = g_strdup_printf(_("Error launching \"%s\": %s"), - command, error->message); - + tmp = g_strdup_printf(_("Error launching %s: %s"), + escaped, error->message); gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); - g_free(tmp); g_error_free(error); } @@ -445,16 +441,16 @@ { if (!g_spawn_command_line_async(command, &error)) { - char *tmp = g_strdup_printf(_("Error launching \"%s\": %s"), - command, error->message); - + tmp = g_strdup_printf(_("Error launching %s: %s"), + escaped, error->message); gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); - g_free(tmp); g_error_free(error); } } + g_free(escaped); + return ret; } #endif /* _WIN32 */ @@ -515,15 +511,15 @@ if (place == GAIM_BROWSER_NEW_WINDOW) remote_command = g_strdup_printf("%s %s -remote " - "\"openURL(\"%s\",new-window)\"", + "\"openURL(%s,new-window)\"", web_browser, args, uri); else if (place == GAIM_BROWSER_NEW_TAB) remote_command = g_strdup_printf("%s %s -remote " - "\"openURL(\"%s\",new-tab)\"", + "\"openURL(%s,new-tab)\"", web_browser, args, uri); else if (place == GAIM_BROWSER_CURRENT) remote_command = g_strdup_printf("%s %s -remote " - "\"openURL(\"%s\")\"", + "\"openURL(%s)\"", web_browser, args, uri); } else if (!strcmp(web_browser, "netscape")) @@ -533,13 +529,13 @@ if (place == GAIM_BROWSER_NEW_WINDOW) { remote_command = g_strdup_printf("netscape -remote " - "\"openURL(\"%s\",new-window)\"", + "\"openURL(%s,new-window)\"", uri); } else if (place == GAIM_BROWSER_CURRENT) { remote_command = g_strdup_printf("netscape -remote " - "\"openURL(\"%s\")\"", uri); + "\"openURL(%s)\"", uri); } } else if (!strcmp(web_browser, "opera")) @@ -551,7 +547,7 @@ else if (place == GAIM_BROWSER_CURRENT) { remote_command = g_strdup_printf("opera -remote " - "\"openURL(\"%s\")\"", uri); + "\"openURL(%s)\"", uri); command = g_strdup_printf("opera \"%s\"", uri); } else diff -r 1e5ef71c9583 -r 8d891252f2ac src/util.c --- a/src/util.c Thu Aug 19 01:13:58 2004 +0000 +++ b/src/util.c Thu Aug 19 01:45:30 2004 +0000 @@ -1652,36 +1652,33 @@ char * gaim_escape_html(const char *html) { - char *escaped = NULL; - - if (html != NULL) { - const char *c = html; - GString *ret = g_string_new(""); - while (*c) { - switch(*c) { - case '&': - ret = g_string_append(ret, "&"); - break; - case '<': - ret = g_string_append(ret, "<"); - break; - case '>': - ret = g_string_append(ret, ">"); - break; - case '"': - ret = g_string_append(ret, """); - break; - default: - ret = g_string_append_c(ret, *c); - } - c++; + const char *c = html; + GString *ret = g_string_new(""); + + if (html == NULL) + return NULL; + + while (*c) { + switch (*c) { + case '&': + ret = g_string_append(ret, "&"); + break; + case '<': + ret = g_string_append(ret, "<"); + break; + case '>': + ret = g_string_append(ret, ">"); + break; + case '"': + ret = g_string_append(ret, """); + break; + default: + ret = g_string_append_c(ret, *c); } - - escaped = ret->str; - g_string_free(ret, FALSE); + c++; } - return escaped; + return g_string_free(ret, FALSE); } char *