pidgin: a79dfe64: Reuse our purple_markup_unescape_entity(...
markdoliner at pidgin.im
markdoliner at pidgin.im
Tue Aug 4 19:50:52 EDT 2009
-----------------------------------------------------------------
Revision: a79dfe640b9fbf5890f59522d1eb39ae3c572548
Ancestor: 7ac42a3144e42153f025f364fbf354b5288e6a9c
Author: markdoliner at pidgin.im
Date: 2009-08-04T23:29:34
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a79dfe640b9fbf5890f59522d1eb39ae3c572548
Modified files:
libpurple/protocols/yahoo/util.c
ChangeLog:
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.
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/util.c 5f3cfb608185f1aabafea045111267ae8f152115
+++ libpurple/protocols/yahoo/util.c 996d28b02e4881a0b4e609100d512f45e9bdfbac
@@ -876,7 +876,7 @@ char *yahoo_html_to_codes(const char *sr
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 @@ char *yahoo_html_to_codes(const char *sr
}
} 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]);
- }
}
}
More information about the Commits
mailing list