changeset 25866:b01a7f17a2bb

Detect duplication registrations by substring. committer: Richard Laager <rlaager@wiktel.com>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 02 Dec 2008 17:20:53 +0000
parents 726b251cb913
children f1d814126801
files pidgin/gtkimhtml.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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);