changeset 28168:64fd19956153

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.
author Mark Doliner <mark@kingant.net>
date Tue, 04 Aug 2009 23:29:34 +0000
parents c859855474ba
children 959a8e51996c
files libpurple/protocols/yahoo/util.c
diffstat 1 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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], "&lt;", 4)) {
-				g_string_append_c(dest, '<');
-				i += 3;
-			} else if (((src_len - i) >= 4) && !strncmp(&src[i], "&gt;", 4)) {
-				g_string_append_c(dest, '>');
-				i += 3;
-			} else if (((src_len - i) >= 5) && !strncmp(&src[i], "&amp;", 5)) {
-				g_string_append_c(dest, '&');
-				i += 4;
-			} else if (((src_len - i) >= 6) && !strncmp(&src[i], "&quot;", 6)) {
-				g_string_append_c(dest, '"');
-				i += 5;
-			} else if (((src_len - i) >= 6) && !strncmp(&src[i], "&apos;", 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]);
-			}
 		}
 	}