# HG changeset patch # User Paul Aurich # Date 1265774750 0 # Node ID 05d727f76ca9a1edea05d1b36225e48296177b47 # Parent 93afc09a5e185d289e85df45003edc997c36d9d1 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". diff -r 93afc09a5e18 -r 05d727f76ca9 ChangeLog.API --- a/ChangeLog.API Wed Feb 10 04:01:16 2010 +0000 +++ b/ChangeLog.API Wed Feb 10 04:05:50 2010 +0000 @@ -13,13 +13,14 @@ * 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) diff -r 93afc09a5e18 -r 05d727f76ca9 libpurple/protocols/bonjour/parser.c --- a/libpurple/protocols/bonjour/parser.c Wed Feb 10 04:01:16 2010 +0000 +++ b/libpurple/protocols/bonjour/parser.c Wed Feb 10 04:05:50 2010 +0000 @@ -49,31 +49,6 @@ 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, diff -r 93afc09a5e18 -r 05d727f76ca9 libpurple/protocols/jabber/parser.c --- a/libpurple/protocols/jabber/parser.c Wed Feb 10 04:01:16 2010 +0000 +++ b/libpurple/protocols/jabber/parser.c Wed Feb 10 04:05:50 2010 +0000 @@ -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, diff -r 93afc09a5e18 -r 05d727f76ca9 libpurple/util.c --- a/libpurple/util.c Wed Feb 10 04:01:16 2010 +0000 +++ b/libpurple/util.c Wed Feb 10 04:05:50 2010 +0000 @@ -2367,6 +2367,31 @@ 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; diff -r 93afc09a5e18 -r 05d727f76ca9 libpurple/util.h --- a/libpurple/util.h Wed Feb 10 04:01:16 2010 +0000 +++ b/libpurple/util.h Wed Feb 10 04:05:50 2010 +0000 @@ -516,18 +516,35 @@ char *purple_markup_linkify(const char *str); /** - * Unescapes HTML entities to their literal characters. Also translates - * "
" to "\n". - * For example "&" is replaced by '&' and so on. + * Unescapes HTML entities to their literal characters in the text. + * For example "&" is replaced by '&' and so on. Also converts + * numerical entities (e.g. "&" is also '&'). + * + * This function currently supports the following named entities: + * "&", "<", ">", "©", """, "®", "'" + * + * purple_unescape_html() is similar, but also converts "
" into "\n". + * + * @param text The string in which to unescape any HTML entities * - * The following named entities are supported (in addition to numerical - * 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 + * "
" 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); diff -r 93afc09a5e18 -r 05d727f76ca9 libpurple/xmlnode.c --- a/libpurple/xmlnode.c Wed Feb 10 04:01:16 2010 +0000 +++ b/libpurple/xmlnode.c Wed Feb 10 04:05:50 2010 +0000 @@ -545,31 +545,6 @@ 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;