# HG changeset patch # User Sadrul Habib Chowdhury # Date 1228238453 0 # Node ID b01a7f17a2bba52d5d3a4d654729dc6283e6b1e2 # Parent 726b251cb913b8669a103526036e40e481cb4dc1 Detect duplication registrations by substring. committer: Richard Laager diff -r 726b251cb913 -r b01a7f17a2bb pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Tue Dec 02 17:20:28 2008 +0000 +++ b/pidgin/gtkimhtml.c Tue Dec 02 17:20:53 2008 +0000 @@ -1411,16 +1411,17 @@ } static GtkIMHtmlProtocol * -imhtml_find_protocol(const char *url) +imhtml_find_protocol(const char *url, gboolean reverse) { GtkIMHtmlClass *klass; GList *iter; GtkIMHtmlProtocol *proto = NULL; + int length = reverse ? strlen(url) : -1; klass = g_type_class_ref(GTK_TYPE_IMHTML); for (iter = klass->protocols; iter; iter = iter->next) { proto = iter->data; - if (g_ascii_strncasecmp(url, proto->name, proto->length) == 0) { + if (g_ascii_strncasecmp(url, proto->name, reverse ? MIN(length, proto->length) : proto->length) == 0) { return proto; } } @@ -1430,7 +1431,7 @@ static void imhtml_url_clicked(GtkIMHtml *imhtml, const char *url) { - GtkIMHtmlProtocol *proto = imhtml_find_protocol(url); + GtkIMHtmlProtocol *proto = imhtml_find_protocol(url, FALSE); GtkIMHtmlLink *link; if (!proto) return; @@ -1790,7 +1791,7 @@ g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", link, (GDestroyNotify)gtk_imhtml_link_destroy); - proto = imhtml_find_protocol(link->url); + proto = imhtml_find_protocol(link->url, FALSE); if (proto && proto->context_menu) { proto->context_menu(GTK_IMHTML(link->imhtml), link, menu); @@ -2386,7 +2387,7 @@ the caller knows how long the protocol string is. */ static int gtk_imhtml_is_protocol(const char *text) { - GtkIMHtmlProtocol *proto = imhtml_find_protocol(text); + GtkIMHtmlProtocol *proto = imhtml_find_protocol(text, FALSE); return proto ? proto->length : 0; } @@ -5756,7 +5757,7 @@ klass = g_type_class_ref(GTK_TYPE_IMHTML); g_return_val_if_fail(klass, FALSE); - if ((proto = imhtml_find_protocol(name))) { + if ((proto = imhtml_find_protocol(name, TRUE))) { g_return_val_if_fail(!activate, FALSE); g_free(proto->name); g_free(proto);