gaim/gaim

Parents d3bf430f3d0c
Children d6e675ec3a0f
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.
--- a/src/gtkimhtml.c Sun Apr 24 13:27:48 2005 -0400
+++ b/src/gtkimhtml.c Sun Apr 24 17:25:58 2005 -0400
@@ -1494,23 +1494,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)