[gaim-migrate @ 12549]

Sun, 24 Apr 2005 21:28:39 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Sun, 24 Apr 2005 21:28:39 +0000
changeset 10865
f5bb66be81a0
parent 10864
dc67964f00ec
child 10866
40eab743e22b

[gaim-migrate @ 12549]
Check all characters in the unescaped value of a HTML entity when matching smileys. Also make sure that the returned value of the smiley length is correct when dealing with escaped text. This resolves an inconsistency between how smileys are detected and how they are looked up for display.

src/gtkimhtml.c file | annotate | diff | comparison | revisions
--- a/src/gtkimhtml.c	Sun Apr 24 21:26:33 2005 +0000
+++ b/src/gtkimhtml.c	Sun Apr 24 21:28:39 2005 +0000
@@ -1656,23 +1656,39 @@
 			break;
 
 		if(*x == '&' && gtk_imhtml_is_amp_escape(x, &amp, &alen)) {
-		    len += alen - strlen(amp);
-		    x += alen - strlen(amp);
-		    pos = strchr (t->values->str, *amp);
+			gboolean matched = TRUE;
+			/* Make sure all chars of the unescaped value match */
+			while (*(amp + 1)) {
+				pos = strchr (t->values->str, *amp);
+				if (pos)
+					t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)];
+				else {
+					matched = FALSE;
+					break;
+				}
+				amp++;
+			}
+			if (!matched)
+				break;
+
+			pos = strchr (t->values->str, *amp);
 		}
 		else if (*x == '<') /* Because we're all WYSIWYG now, a '<' 
 				     * char should only appear as the start of a tag.  Perhaps a safer (but costlier)
 				     * check would be to call gtk_imhtml_is_tag on it */
 			break;
-		else
-		    pos = strchr (t->values->str, *x);
+		else {
+			alen = 1;
+			pos = strchr (t->values->str, *x);
+		}
 
 		if (pos)
 			t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)];
 		else
 			break;
 
-		x++; len++;
+		x += alen;
+		len += alen;
 	}
 
 	if (t->image)

mercurial