pidgin.next.minor: 8761a764: Combine the three purple_unescape_text()...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue Feb 9 23:11:53 EST 2010


-----------------------------------------------------------------
Revision: 8761a76439ad0ebb03090ebdd75ca3aa5422d105
Ancestor: 92de1a07684ff3a7bb4a9513f33b7d6c6416aced
Author: darkrain42 at pidgin.im
Date: 2010-02-10T04:05:50
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/8761a76439ad0ebb03090ebdd75ca3aa5422d105

Modified files:
        ChangeLog.API libpurple/protocols/bonjour/parser.c
        libpurple/protocols/jabber/parser.c libpurple/util.c
        libpurple/util.h libpurple/xmlnode.c

ChangeLog: 

Combine the three purple_unescape_text()s into one.

purple_unescape_text is like purple_unescape_html, except better.  I say
better, but really, what I should say is "libxml2 BLOWS", because of its
crazy way of leaving attributes "unescaped".


-------------- next part --------------
============================================================
--- ChangeLog.API	0bfeb827bf01f98dce41e51996b2b08e51e9ee10
+++ ChangeLog.API	bfe165f5ce67328f7ea9ef6cfdb716d6f14423b5
@@ -13,13 +13,14 @@ version 2.7.0 (??/??/????):
 		* purple_media_manager_set_backend_type
 		* purple_network_get_all_local_system_ips
 		* purple_prpl_got_media_caps
+		* purple_unescape_text
 		* purple_uuid_random
 		* media_caps to the PurpleBuddy struct
 		* buddy-caps-changed blist signal
 		* ui-caps-changed media manager signal
 		* sent-attention conversation signal
 		* got-attention conversation signal
-	
+
 	Pidgin:
 		Added:
 		* pidgin_dialogs_buildinfo (should not be used by anything but Pidgin)
============================================================
--- libpurple/protocols/bonjour/parser.c	44aea64497948e68cb2f7a9a8aefdcc2bcf14191
+++ libpurple/protocols/bonjour/parser.c	25d9be610ce4232b12fb4a510bdfd0a65b7fc55e
@@ -49,31 +49,6 @@ parse_from_attrib_and_find_buddy(Bonjour
 	return FALSE;
 }
 
-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
 bonjour_parser_element_start_libxml(void *user_data,
 				   const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace,
============================================================
--- libpurple/protocols/jabber/parser.c	92ff195cea10bcd9084fa67882743fb2026c9e5e
+++ libpurple/protocols/jabber/parser.c	58c4da2571d7be0486bbf851b13ca7c204c05469
@@ -31,31 +31,6 @@
 #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,
============================================================
--- libpurple/util.c	07e58ec25febecc4b228f4ad392a4062170863b3
+++ libpurple/util.c	bdfd6f3c4e0d3bbd079fb9d289172318aa47fa9e
@@ -2367,6 +2367,31 @@ purple_markup_linkify(const char *text)
 	return g_string_free(ret, FALSE);
 }
 
+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);
+}
+
 char *purple_unescape_html(const char *html)
 {
 	GString *ret;
============================================================
--- libpurple/util.h	1ff013c525a626cb2a0fd6f5114ae95d560d0975
+++ libpurple/util.h	db948b56acc0167c5b758136544aac5f13c585e2
@@ -516,18 +516,35 @@ char *purple_markup_linkify(const char *
 char *purple_markup_linkify(const char *str);
 
 /**
- * Unescapes HTML entities to their literal characters. Also translates
- * "<br>" to "\n".
- * For example "&amp;" is replaced by '&' and so on.
+ * Unescapes HTML entities to their literal characters in the text.
+ * For example "&amp;" is replaced by '&' and so on.  Also converts
+ * numerical entities (e.g. "&#38;" is also '&').
  *
- * The following named entities are supported (in addition to numerical
- * entities):
- *    "&amp;", "&lt;", "&gt;", "&copy;", "&quot;", "&reg;", "&apos;"
+ * This function currently supports the following named entities:
+ *     "&amp;", "&lt;", "&gt;", "&copy;", "&quot;", "&reg;", "&apos;"
  *
+ * purple_unescape_html() is similar, but also converts "<br>" into "\n".
+ *
+ * @param text The string in which to unescape any HTML entities
+ *
+ * @return The text with HTML entities literalized.  You must g_free
+ *         this string when finished with it.
+ *
+ * @see purple_unescape_html()
+ * @since 2.7.0
+ */
+char *purple_unescape_text(const char *text);
+
+/**
+ * Unescapes HTML entities to their literal characters and converts
+ * "<br>" to "\n".  See purple_unescape_text() for more details.
+ *
  * @param html The string in which to unescape any HTML entities
  *
  * @return The text with HTML entities literalized.  You must g_free
  *         this string when finished with it.
+ *
+ * @see purple_unescape_text()
  */
 char *purple_unescape_html(const char *html);
 
============================================================
--- libpurple/xmlnode.c	481da12a6cdd695e349a0ed4c7a68bf213895817
+++ libpurple/xmlnode.c	429717b4288ea43ffac689e5081bd55f7decf433
@@ -545,31 +545,6 @@ xmlnode_to_formatted_str(const xmlnode *
 	return xml_with_declaration;
 }
 
-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);
-}
-
 struct _xmlnode_parser_data {
 	xmlnode *current;
 	gboolean error;


More information about the Commits mailing list