comparison libpurple/xmlnode.c @ 29753: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 e1c01f236674
children 77cd42f08ba1
comparison
equal deleted inserted replaced
29752:93afc09a5e18 29753:05d727f76ca9
541 541
542 if (len) 542 if (len)
543 *len += sizeof("<?xml version='1.0' encoding='UTF-8' ?>" NEWLINE_S NEWLINE_S) - 1; 543 *len += sizeof("<?xml version='1.0' encoding='UTF-8' ?>" NEWLINE_S NEWLINE_S) - 1;
544 544
545 return xml_with_declaration; 545 return xml_with_declaration;
546 }
547
548 static char *purple_unescape_text(const char *in)
549 {
550 GString *ret;
551 const char *c = in;
552
553 if (in == NULL)
554 return NULL;
555
556 ret = g_string_new("");
557 while (*c) {
558 int len;
559 const char *ent;
560
561 if ((ent = purple_markup_unescape_entity(c, &len)) != NULL) {
562 g_string_append(ret, ent);
563 c += len;
564 } else {
565 g_string_append_c(ret, *c);
566 c++;
567 }
568 }
569
570 return g_string_free(ret, FALSE);
571 } 546 }
572 547
573 struct _xmlnode_parser_data { 548 struct _xmlnode_parser_data {
574 xmlnode *current; 549 xmlnode *current;
575 gboolean error; 550 gboolean error;