Thu, 22 Sep 2016 22:09:22 -0500
Add our license spiel to a bunch of files
|
38057
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
1 | /* |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
2 | * purple |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
3 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
6 | * source distribution. |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
7 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
11 | * (at your option) any later version. |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
12 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
16 | * GNU General Public License for more details. |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
17 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
21 | * |
|
41f47eb1aa19
Add our license spiel to a bunch of files
Gary Kramlich <grim@reaperworld.com>
parents:
37607
diff
changeset
|
22 | */ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
23 | #include <glib.h> |
|
31891
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
24 | |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
25 | #include "../xmlnode.h" |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
26 | |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
27 | /* |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
28 | * If we really wanted to test the billion laughs attack we would |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
29 | * need to have more than just 4 ha's. But as long as this shorter |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
30 | * document fails to parse, the longer one should also fail to parse. |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
31 | */ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
32 | static void |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
33 | test_xmlnode_billion_laughs_attack(void) { |
|
31891
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
34 | const char *malicious_xml_doc = "<!DOCTYPE root [ <!ENTITY ha \"Ha !\"><!ENTITY ha2 \"&ha; &ha;\"><!ENTITY ha3 \"&ha2; &ha2;\"> ]><root>&ha3;</root>"; |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
35 | |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
36 | /* Uncomment this line if you want to see the error message given by |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
37 | the parser for the above XML document */ |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
38 | /* purple_debug_set_enabled(TRUE); */ |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
39 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
40 | g_assert_null(purple_xmlnode_from_str(malicious_xml_doc, -1)); |
|
31891
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
41 | } |
|
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
42 | |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
43 | #define check_doc_structure(x) { \ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
44 | PurpleXmlNode *ping, *child1, *child2; \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
45 | g_assert_nonnull(x); \ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
46 | ping = purple_xmlnode_get_child(x, "ping"); \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
47 | g_assert_nonnull(ping); \ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
48 | child1 = purple_xmlnode_get_child(ping, "child1"); \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
49 | g_assert_nonnull(child1); \ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
50 | child2 = purple_xmlnode_get_child(child1, "child2"); \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
51 | g_assert_nonnull(child2); \ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
52 | purple_xmlnode_new_child(child2, "a"); \ |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
53 | \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
54 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_namespace(x)); \ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
55 | /* NOTE: purple_xmlnode_get_namespace() returns the namespace of the element, not the |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
56 | * current default namespace. See http://www.w3.org/TR/xml-names/#defaulting and |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
57 | * http://www.w3.org/TR/xml-names/#dt-defaultNS. |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
58 | */ \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
59 | g_assert_cmpstr("urn:xmpp:ping", ==, purple_xmlnode_get_namespace(ping)); \ |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
60 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_namespace(child1)); \ |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
61 | g_assert_cmpstr("urn:xmpp:ping", ==, purple_xmlnode_get_namespace(child2)); \ |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
62 | /* |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
63 | * This fails (well, actually crashes [the ns is NULL]) unless |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
64 | * purple_xmlnode_new_child() actually sets the element namespace. |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
65 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_namespace(purple_xmlnode_get_child(child2, "a"))); |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
66 | */ \ |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
67 | \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
68 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_default_namespace(x)); \ |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
69 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_default_namespace(ping)); \ |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
70 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_default_namespace(child1)); \ |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
71 | g_assert_cmpstr("jabber:client", ==, purple_xmlnode_get_default_namespace(child2)); \ |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
72 | } |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
73 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
74 | static void |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
75 | test_xmlnode_prefixes(void) { |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
76 | const char *xml_doc = |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
77 | "<iq type='get' xmlns='jabber:client' xmlns:ping='urn:xmpp:ping'>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
78 | "<ping:ping>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
79 | "<child1>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
80 | "<ping:child2></ping:child2>" /* xmlns='jabber:child' */ |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
81 | "</child1>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
82 | "</ping:ping>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
83 | "</iq>"; |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
84 | char *str; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
85 | PurpleXmlNode *xml, *reparsed; |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
86 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
87 | xml = purple_xmlnode_from_str(xml_doc, -1); |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
88 | check_doc_structure(xml); |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
89 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
90 | /* Check that purple_xmlnode_from_str(purple_xmlnode_to_str(xml, NULL), -1) is idempotent. */ |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
91 | str = purple_xmlnode_to_str(xml, NULL); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
92 | g_assert_nonnull(str); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
93 | reparsed = purple_xmlnode_from_str(str, -1); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
94 | g_assert_nonnull(reparsed); |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
95 | check_doc_structure(reparsed); |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
96 | |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
97 | g_free(str); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
98 | purple_xmlnode_free(xml); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
99 | purple_xmlnode_free(reparsed); |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
100 | } |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
101 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
102 | static void |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
103 | test_strip_prefixes(void) { |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
104 | const char *xml_doc = "<message xmlns='jabber:client' from='user@gmail.com/resource' to='another_user@darkrain42.org' type='chat' id='purple'>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
105 | "<cha:active xmlns:cha='http://jabber.org/protocol/chatstates'/>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
106 | "<body>xvlc xvlc</body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
107 | "<im:html xmlns:im='http://jabber.org/protocol/xhtml-im'>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
108 | "<xht:body xmlns:xht='http://www.w3.org/1999/xhtml'>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
109 | "<xht:p>xvlc <xht:span style='font-weight: bold;'>xvlc</xht:span></xht:p>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
110 | "</xht:body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
111 | "</im:html>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
112 | "</message>"; |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
113 | const char *out = "<message xmlns='jabber:client' from='user@gmail.com/resource' to='another_user@darkrain42.org' type='chat' id='purple'>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
114 | "<active xmlns:cha='http://jabber.org/protocol/chatstates' xmlns='http://jabber.org/protocol/chatstates'/>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
115 | "<body>xvlc xvlc</body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
116 | "<html xmlns:im='http://jabber.org/protocol/xhtml-im' xmlns='http://jabber.org/protocol/xhtml-im'>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
117 | "<body xmlns:xht='http://www.w3.org/1999/xhtml' xmlns='http://www.w3.org/1999/xhtml'>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
118 | "<p>xvlc <span style='font-weight: bold;'>xvlc</span></p>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
119 | "</body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
120 | "</html>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
121 | "</message>"; |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
122 | char *str; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
123 | PurpleXmlNode *xml; |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
124 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
125 | xml = purple_xmlnode_from_str(xml_doc, -1); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
126 | g_assert_nonnull(xml); |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
127 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
128 | purple_xmlnode_strip_prefixes(xml); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
129 | str = purple_xmlnode_to_str(xml, NULL); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
130 | g_assert_cmpstr(out, ==, str); |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
131 | g_free(str); |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
132 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
133 | purple_xmlnode_free(xml); |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
134 | } |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
135 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
136 | gint |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
137 | main(gint argc, gchar **argv) { |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
138 | g_test_init(&argc, &argv, NULL); |
|
31891
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
139 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
140 | g_test_add_func("/xmlnode/billion_laughs_attack", |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
141 | test_xmlnode_billion_laughs_attack); |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
142 | g_test_add_func("/xmlnode/prefixes", |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
143 | test_xmlnode_prefixes); |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
144 | g_test_add_func("/xmlnode/strip_prefixes", |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
145 | test_strip_prefixes); |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
146 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
147 | return g_test_run(); |
|
31891
186f61a85ac2
Add a silly little check to make sure our xml parser isn't vulnerable to the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
148 | } |