diff libpurple/protocols/jabber/parser.c @ 29006:e1c01f236674

Correctly parse "<br>" in an XML attribute. Closes #11318. If nobody has objections, I intend to add purple_unescape_text() to util.[ch] for 2.7.0.
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Feb 2010 03:32:29 +0000
parents d558d141aaae
children 05d727f76ca9
line wrap: on
line diff
--- a/libpurple/protocols/jabber/parser.c	Tue Feb 09 06:56:00 2010 +0000
+++ b/libpurple/protocols/jabber/parser.c	Wed Feb 10 03:32:29 2010 +0000
@@ -31,6 +31,31 @@
 #include "util.h"
 #include "xmlnode.h"
 
+static char *purple_unescape_text(const char *in)
+{
+    GString *ret;
+    const char *c = in;
+
+    if (in == NULL)
+        return NULL;
+
+    ret = g_string_new("");
+    while (*c) {
+        int len;
+        const char *ent;
+
+        if ((ent = purple_markup_unescape_entity(c, &len)) != NULL) {
+            g_string_append(ret, ent);
+            c += len;
+        } else {
+            g_string_append_c(ret, *c);
+            c++;
+        }
+    }
+
+    return g_string_free(ret, FALSE);
+}
+
 static void
 jabber_parser_element_start_libxml(void *user_data,
 				   const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace,
@@ -89,7 +114,7 @@
 			char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len);
 
 			txt = attrib;
-			attrib = purple_unescape_html(txt);
+			attrib = purple_unescape_text(txt);
 			g_free(txt);
 			xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib);
 			g_free(attrib);