# HG changeset patch # User Mark Doliner # Date 1249428574 0 # Node ID 64fd19956153448ee7b59c57ed10bcedb0f7d8c8 # Parent c859855474ba79f8d035955b8b8342942916a242 Reuse our purple_markup_unescape_entity() function instead of duplicating the functionality here. purple_markup_unescape_entity() supports a wider range of HTML entities. This code probably shouldn't have been checking to make sure src was long enough. diff -r c859855474ba -r 64fd19956153 libpurple/protocols/yahoo/util.c --- a/libpurple/protocols/yahoo/util.c Tue Aug 04 22:47:58 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Tue Aug 04 23:29:34 2009 +0000 @@ -876,7 +876,7 @@ for (i = 0; i < src_len; i++) { - if (!no_more_specials && src[i] == '<') { + if (src[i] == '<' && !no_more_specials) { j = i; while (1) { @@ -1033,24 +1033,17 @@ } } else { - if (((src_len - i) >= 4) && !strncmp(&src[i], "<", 4)) { - g_string_append_c(dest, '<'); - i += 3; - } else if (((src_len - i) >= 4) && !strncmp(&src[i], ">", 4)) { - g_string_append_c(dest, '>'); - i += 3; - } else if (((src_len - i) >= 5) && !strncmp(&src[i], "&", 5)) { - g_string_append_c(dest, '&'); - i += 4; - } else if (((src_len - i) >= 6) && !strncmp(&src[i], """, 6)) { - g_string_append_c(dest, '"'); - i += 5; - } else if (((src_len - i) >= 6) && !strncmp(&src[i], "'", 6)) { - g_string_append_c(dest, '\''); - i += 5; - } else { + const char *entity; + int length; + + entity = purple_markup_unescape_entity(src + i, &length); + if (entity != NULL) { + /* src[i] is the start of an HTML entity */ + g_string_append(dest, entity); + i += length - 1; + } else + /* src[i] is a normal character */ g_string_append_c(dest, src[i]); - } } }