# HG changeset patch # User tdrhq@soc.pidgin.im # Date 1249670667 0 # Node ID 2af29d62cfde21096bdff6c0ec6ad7163d3c1ccc # Parent a2fd5f08ed49920a1223a3ee97dbd7a5dcb00058 more cleanup. diff -r a2fd5f08ed49 -r 2af29d62cfde pidgin/gtkwebview.c --- a/pidgin/gtkwebview.c Fri Aug 07 18:38:31 2009 +0000 +++ b/pidgin/gtkwebview.c Fri Aug 07 18:44:27 2009 +0000 @@ -109,7 +109,7 @@ if (!cur) cur = strstr (img, ">"); - if (!cur) { /*oops, invalid html */ + if (!cur) { /* invalid html? */ g_string_printf (buffer, "%s", html); break; } @@ -119,8 +119,12 @@ break; } - /* now I _kinda_ know that it has an id=, and does not have a src= */ - /* todo: take care of src= and id= appearing in strings? */ + /* + * if this is valid HTML, then I can be sure that it + * has an id= and does not have an src=, since + * '=' cannot appear in parameters. + */ + id = strstr (img, "id=") + 3; /* *id can't be \0, since a ">" appears after this */ @@ -134,6 +138,7 @@ g_string_append_printf (buffer, " src='file://%s' ", get_image_filename_from_id (view, nid)); } + return g_string_free (buffer, FALSE); } @@ -153,9 +158,9 @@ static gboolean webview_link_clicked (WebKitWebView *view, - WebKitWebFrame *frame, - WebKitNetworkRequest *request, - WebKitWebNavigationAction *navigation_action, + WebKitWebFrame *frame, + WebKitNetworkRequest *request, + WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision) { const gchar *uri; @@ -209,7 +214,6 @@ g_free (html_imged); } -/* taken from sean's webkit plugin */ char *gtk_webview_quote_js_string(const char *text) { GString *str = g_string_new("\""); @@ -275,7 +279,7 @@ GType gtk_webview_get_type () { static GType mview_type = 0; - if (!mview_type) { + if (G_UNLIKELY (mview_type == 0)) { static const GTypeInfo mview_info = { sizeof (GtkWebViewClass), NULL,