Mercurial > pidgin
diff libpurple/util.c @ 29359:05d727f76ca9
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".
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 10 Feb 2010 04:05:50 +0000 |
parents | 422889fb57e0 |
children | 41142f2bcafb |
line wrap: on
line diff
--- 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;