pidgin.next.minor: 61948e1f: Detect duplication registrations by subs...
rlaager at pidgin.im
rlaager at pidgin.im
Tue Dec 2 13:50:27 EST 2008
-----------------------------------------------------------------
Revision: 61948e1fee73116aa5b5d9a9eb01f524f462ae21
Ancestor: 62f07bce9cd9815006906e75cfa946c585d9ebdf
Author: sadrul at pidgin.im
Date: 2008-12-02T17:20:53
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/61948e1fee73116aa5b5d9a9eb01f524f462ae21
Modified files:
pidgin/gtkimhtml.c
ChangeLog:
Detect duplication registrations by substring.
-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c 13b245ed708c664d90ca3e9a530e42f72a07a116
+++ pidgin/gtkimhtml.c 33ccada9683c83d512d7e07c6e8b4574e8b31790
@@ -1411,16 +1411,17 @@ static GtkIMHtmlProtocol *
}
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 @@ imhtml_url_clicked(GtkIMHtml *imhtml, co
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 @@ static gboolean tag_event(GtkTextTag *ta
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 @@ static int gtk_imhtml_is_protocol(const
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 @@ gboolean gtk_imhtml_class_register_proto
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);
More information about the Commits
mailing list