Mercurial > pidgin
comparison libpurple/xmlnode.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 | 981374c7308b |
children | 05d727f76ca9 |
comparison
equal
deleted
inserted
replaced
29005:9b0d3a48a467 | 29006:e1c01f236674 |
---|---|
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 } | 546 } |
547 | 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 } | |
572 | |
548 struct _xmlnode_parser_data { | 573 struct _xmlnode_parser_data { |
549 xmlnode *current; | 574 xmlnode *current; |
550 gboolean error; | 575 gboolean error; |
551 }; | 576 }; |
552 | 577 |
588 const char *prefix = (const char *)attributes[i+1]; | 613 const char *prefix = (const char *)attributes[i+1]; |
589 char *txt; | 614 char *txt; |
590 int attrib_len = attributes[i+4] - attributes[i+3]; | 615 int attrib_len = attributes[i+4] - attributes[i+3]; |
591 char *attrib = g_strndup((const char *)attributes[i+3], attrib_len); | 616 char *attrib = g_strndup((const char *)attributes[i+3], attrib_len); |
592 txt = attrib; | 617 txt = attrib; |
593 attrib = purple_unescape_html(txt); | 618 attrib = purple_unescape_text(txt); |
594 g_free(txt); | 619 g_free(txt); |
595 xmlnode_set_attrib_full(node, name, NULL, prefix, attrib); | 620 xmlnode_set_attrib_full(node, name, NULL, prefix, attrib); |
596 g_free(attrib); | 621 g_free(attrib); |
597 } | 622 } |
598 | 623 |