diff src/gtkimhtml.c @ 10865:c28766b87f64

[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. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 24 Apr 2005 21:28:39 +0000
parents a29815b897c0
children 6240d7fd5b2c
line wrap: on
line diff
--- 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)