Fri, 11 Mar 2022 03:29:48 -0600
Add an echo user to the demo protocol
Testing Done:
Opened a conversation and typed a few message.
Reviewed at https://reviews.imfreedom.org/r/1328/
|
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 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
38057
diff
changeset
|
25 | #include <purple.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
|
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) { |
|
41129
4be9a7876d35
Fix the unit tests that were broke by the g_log transition
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
34 | if(g_test_subprocess()) { |
|
4be9a7876d35
Fix the unit tests that were broke by the g_log transition
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
35 | const char *malicious_xml_doc = "<!DOCTYPE root [ <!ENTITY ha \"Ha !\"><!ENTITY ha2 \"&ha; &ha;\"><!ENTITY ha3 \"&ha2; &ha2;\"> ]><root>&ha3;</root>"; |
|
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
|
36 | |
|
41129
4be9a7876d35
Fix the unit tests that were broke by the g_log transition
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
37 | g_assert_null(purple_xmlnode_from_str(malicious_xml_doc, -1)); |
|
4be9a7876d35
Fix the unit tests that were broke by the g_log transition
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
38 | } |
|
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
|
39 | |
|
41129
4be9a7876d35
Fix the unit tests that were broke by the g_log transition
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
40 | g_test_trap_subprocess(NULL, 0, 0); |
|
4be9a7876d35
Fix the unit tests that were broke by the g_log transition
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
41 | g_test_trap_assert_stderr("*CRITICAL*Entity 'ha3' not defined*"); |
|
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
|
42 | } |
|
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
|
43 | |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
44 | #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
|
45 | PurpleXmlNode *ping, *child1, *child2; \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
46 | 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
|
47 | ping = purple_xmlnode_get_child(x, "ping"); \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
48 | 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
|
49 | child1 = purple_xmlnode_get_child(ping, "child1"); \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
50 | 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
|
51 | child2 = purple_xmlnode_get_child(child1, "child2"); \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
52 | 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
|
53 | 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
|
54 | \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
55 | 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
|
56 | /* 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
|
57 | * 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
|
58 | * 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
|
59 | */ \ |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | /* |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
64 | * 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
|
65 | * 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
|
66 | 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
|
67 | */ \ |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
68 | \ |
|
37607
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(x)); \ |
|
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(ping)); \ |
|
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(child1)); \ |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
72 | 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
|
73 | } |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
74 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
75 | static void |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
76 | 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
|
77 | const char *xml_doc = |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
78 | "<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
|
79 | "<ping:ping>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
80 | "<child1>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
81 | "<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
|
82 | "</child1>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
83 | "</ping:ping>" |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
84 | "</iq>"; |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
85 | char *str; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
86 | PurpleXmlNode *xml, *reparsed; |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
87 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
88 | 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
|
89 | check_doc_structure(xml); |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
90 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
91 | /* 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
|
92 | str = purple_xmlnode_to_str(xml, NULL); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
93 | 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
|
94 | reparsed = purple_xmlnode_from_str(str, -1); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
95 | 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
|
96 | check_doc_structure(reparsed); |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
97 | |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
98 | 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
|
99 | 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
|
100 | 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
|
101 | } |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
102 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
103 | static void |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
104 | test_strip_prefixes(void) { |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
105 | 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
|
106 | "<cha:active xmlns:cha='http://jabber.org/protocol/chatstates'/>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
107 | "<body>xvlc xvlc</body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
108 | "<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
|
109 | "<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
|
110 | "<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
|
111 | "</xht:body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
112 | "</im:html>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
113 | "</message>"; |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
114 | 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
|
115 | "<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
|
116 | "<body>xvlc xvlc</body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
117 | "<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
|
118 | "<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
|
119 | "<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
|
120 | "</body>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
121 | "</html>" |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
122 | "</message>"; |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
123 | char *str; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
124 | PurpleXmlNode *xml; |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
125 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
126 | 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
|
127 | g_assert_nonnull(xml); |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
128 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
129 | 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
|
130 | str = purple_xmlnode_to_str(xml, NULL); |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
131 | g_assert_cmpstr(out, ==, str); |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
132 | g_free(str); |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
133 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
32322
diff
changeset
|
134 | purple_xmlnode_free(xml); |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
135 | } |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
136 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
137 | gint |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
138 | main(gint argc, gchar **argv) { |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
139 | 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
|
140 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
141 | g_test_add_func("/xmlnode/billion_laughs_attack", |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
142 | test_xmlnode_billion_laughs_attack); |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
143 | g_test_add_func("/xmlnode/prefixes", |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
144 | test_xmlnode_prefixes); |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
145 | g_test_add_func("/xmlnode/strip_prefixes", |
|
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
146 | test_strip_prefixes); |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
31891
diff
changeset
|
147 | |
|
37607
773815a9a48f
Convert the xmlnode tests to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
34935
diff
changeset
|
148 | 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
|
149 | } |