Mercurial > pidgin
annotate libpurple/protocols/jabber/parser.c @ 30449:ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
The requirement that there be an ID on the responder's header was
underspecified/just a SHOULD (depending on how you read it)
in rfc3920.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 27 Aug 2010 05:14:08 +0000 |
parents | 6e598ca344b3 |
children | 4072761e3454 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple - Jabber XML parser stuff |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28048
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27137
diff
changeset
|
6 * source distribution. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15822
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include <libxml/parser.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "connection.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "jabber.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "parser.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "xmlnode.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 jabber_parser_element_start_libxml(void *user_data, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 int nb_namespaces, const xmlChar **namespaces, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 int nb_attributes, int nb_defaulted, const xmlChar **attributes) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 JabberStream *js = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 xmlnode *node; |
24853
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
42 int i, j; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 if(!element_name) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 return; |
29602
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
46 } else if (js->stream_id == NULL) { |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
47 /* Sanity checking! */ |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
48 if (0 != xmlStrcmp(element_name, (xmlChar *) "stream") || |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
49 0 != xmlStrcmp(namespace, (xmlChar *) NS_XMPP_STREAMS)) { |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
50 /* We were expecting a <stream:stream/> opening stanza, but |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
51 * didn't get it. Bad! |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
52 */ |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
53 purple_debug_error("jabber", "Expecting stream header, got %s with " |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
54 "xmlns %s\n", element_name, namespace); |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
55 purple_connection_error_reason(js->gc, |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
56 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
57 _("XMPP stream header missing")); |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
58 return; |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
59 } |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
60 |
29561
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
61 js->protocol_version.major = 0; |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
62 js->protocol_version.minor = 9; |
29602
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
63 |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
64 for (i = 0; i < nb_attributes * 5; i += 5) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 int attrib_len = attributes[i+4] - attributes[i+3]; |
28726
f6f35d5960e9
Use g_strndup() for great justice.
Paul Aurich <paul@darkrain42.org>
parents:
28681
diff
changeset
|
66 char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
29561
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
68 if(!xmlStrcmp(attributes[i], (xmlChar*) "version")) { |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
69 const char *dot = strchr(attrib, '.'); |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
70 |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
71 js->protocol_version.major = atoi(attrib); |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
72 js->protocol_version.minor = dot ? atoi(dot + 1) : 0; |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
73 |
29602
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
74 if (js->protocol_version.major > 1) { |
29564
9d1794da1d10
jabber: Connected again; checked section 5.4.5 of the bis.
Paul Aurich <paul@darkrain42.org>
parents:
29563
diff
changeset
|
75 /* TODO: Send <unsupported-version/> error */ |
29561
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
76 purple_connection_error_reason(js->gc, |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
77 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
78 _("XMPP Version Mismatch")); |
29602
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
79 g_free(attrib); |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
80 return; |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
81 } |
29562
32fe87f58d06
jabber: Backward compatibility in case any servers advertise other random 0.## versions
Paul Aurich <paul@darkrain42.org>
parents:
29561
diff
changeset
|
82 |
32fe87f58d06
jabber: Backward compatibility in case any servers advertise other random 0.## versions
Paul Aurich <paul@darkrain42.org>
parents:
29561
diff
changeset
|
83 if (js->protocol_version.major == 0 && js->protocol_version.minor != 9) { |
32fe87f58d06
jabber: Backward compatibility in case any servers advertise other random 0.## versions
Paul Aurich <paul@darkrain42.org>
parents:
29561
diff
changeset
|
84 purple_debug_warning("jabber", "Treating version %s as 0.9 for backward " |
32fe87f58d06
jabber: Backward compatibility in case any servers advertise other random 0.## versions
Paul Aurich <paul@darkrain42.org>
parents:
29561
diff
changeset
|
85 "compatibility\n", attrib); |
32fe87f58d06
jabber: Backward compatibility in case any servers advertise other random 0.## versions
Paul Aurich <paul@darkrain42.org>
parents:
29561
diff
changeset
|
86 } |
32fe87f58d06
jabber: Backward compatibility in case any servers advertise other random 0.## versions
Paul Aurich <paul@darkrain42.org>
parents:
29561
diff
changeset
|
87 g_free(attrib); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) { |
15634
baec42670246
Patch from MatsMattsson (Adium Trac #6429) which fixes a leak of attrib for any attribute that isn't 'id' or 'version'.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15497
diff
changeset
|
89 g_free(js->stream_id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 js->stream_id = attrib; |
15634
baec42670246
Patch from MatsMattsson (Adium Trac #6429) which fixes a leak of attrib for any attribute that isn't 'id' or 'version'.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15497
diff
changeset
|
91 } else { |
24853
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
92 g_free(attrib); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 } |
29602
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
95 |
30449
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
96 if (js->stream_id == NULL) { |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
97 #if 0 |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
98 /* This was underspecified in rfc3920 as only being a SHOULD, so |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
99 * we cannot rely on it. See #12331 and Oracle's server. |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
100 */ |
29602
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
101 purple_connection_error_reason(js->gc, |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
102 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
6e598ca344b3
jabber: Clear the stream header when restarting a stream, and be
Paul Aurich <paul@darkrain42.org>
parents:
29564
diff
changeset
|
103 _("XMPP stream missing ID")); |
30449
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
104 #else |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
105 /* Instead, let's make up a fancy-schmancy stream ID, which |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
106 * we need to do because we flag on js->stream_id == NULL being |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
107 * a special case in this function. |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
108 */ |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
109 js->stream_id = purple_uuid_random(); |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
110 #endif |
ec12d2883266
jabber: Make the reliance on stream ID laxer. Closes #12331
Paul Aurich <paul@darkrain42.org>
parents:
29602
diff
changeset
|
111 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 if(js->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 node = xmlnode_new_child(js->current, (const char*) element_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 node = xmlnode_new((const char*) element_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 xmlnode_set_namespace(node, (const char*) namespace); |
24853
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
119 xmlnode_set_prefix(node, (const char *)prefix); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 |
24853
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
121 if (nb_namespaces != 0) { |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
122 node->namespace_map = g_hash_table_new_full( |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
123 g_str_hash, g_str_equal, g_free, g_free); |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
124 |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
125 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) { |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
126 const char *key = (const char *)namespaces[j]; |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
127 const char *val = (const char *)namespaces[j + 1]; |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
128 g_hash_table_insert(node->namespace_map, |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
129 g_strdup(key ? key : ""), g_strdup(val ? val : "")); |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
130 } |
f5c0cdaef99a
Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents:
24480
diff
changeset
|
131 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 for(i=0; i < nb_attributes * 5; i+=5) { |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25476
diff
changeset
|
133 const char *name = (const char *)attributes[i]; |
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25476
diff
changeset
|
134 const char *prefix = (const char *)attributes[i+1]; |
25476
b096f7fb6899
Don't set an attribute prefix on the node, and remove an unnecessary call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24926
diff
changeset
|
135 const char *attrib_ns = (const char *)attributes[i+2]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 char *txt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 int attrib_len = attributes[i+4] - attributes[i+3]; |
28726
f6f35d5960e9
Use g_strndup() for great justice.
Paul Aurich <paul@darkrain42.org>
parents:
28681
diff
changeset
|
138 char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 txt = attrib; |
29006
e1c01f236674
Correctly parse "<br>" in an XML attribute. Closes #11318.
Paul Aurich <paul@darkrain42.org>
parents:
28744
diff
changeset
|
141 attrib = purple_unescape_text(txt); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 g_free(txt); |
26180
b03430dae08e
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25476
diff
changeset
|
143 xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 g_free(attrib); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 js->current = node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 jabber_parser_element_end_libxml(void *user_data, const xmlChar *element_name, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 const xmlChar *prefix, const xmlChar *namespace) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 JabberStream *js = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 if(!js->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 if(js->current->parent) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 if(!xmlStrcmp((xmlChar*) js->current->name, element_name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 js->current = js->current->parent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 xmlnode *packet = js->current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 js->current = NULL; |
17894
bbd92ee894f2
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17879
diff
changeset
|
166 jabber_process_packet(js, &packet); |
24480
7cf760f3560e
Don't try to free NULL xmlnodes stolen by jabber-receiving-xmlnode handlers
Will Thompson <will.thompson@collabora.co.uk>
parents:
24474
diff
changeset
|
167 if (packet != NULL) |
7cf760f3560e
Don't try to free NULL xmlnodes stolen by jabber-receiving-xmlnode handlers
Will Thompson <will.thompson@collabora.co.uk>
parents:
24474
diff
changeset
|
168 xmlnode_free(packet); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 jabber_parser_element_text_libxml(void *user_data, const xmlChar *text, int text_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 JabberStream *js = user_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 if(!js->current) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 if(!text || !text_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 xmlnode_insert_data(js->current, (const char*) text, text_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 |
23424
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
186 static void |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
187 jabber_parser_structured_error_handler(void *user_data, xmlErrorPtr error) |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
188 { |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
189 JabberStream *js = user_data; |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
190 |
24471
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
191 if (error->level == XML_ERR_WARNING && error->message != NULL |
28681 | 192 && g_str_equal(error->message, "xmlns: URI vcard-temp is not absolute\n")) |
24471
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
193 /* |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
194 * This message happens when parsing vcards, and is normal, so don't |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
195 * bother logging it because people scare easily. |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
196 */ |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
197 return; |
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
198 |
28727
6ebacc1710b2
jabber: Use the error code instead of string matching.
Paul Aurich <paul@darkrain42.org>
parents:
28726
diff
changeset
|
199 if (error->level == XML_ERR_FATAL && error->code == XML_ERR_DOCUMENT_END) |
28652
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
200 /* |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
201 * This is probably more annoying than the vcard-temp error; it occurs |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
202 * because we disconnect in most cases without waiting for the receiving |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
203 * </stream:stream> (limitations of libpurple) |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
204 */ |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
205 return; |
61cd675b73df
jabber: Don't print "Extra content at the end of the document".
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
206 |
23424
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
207 purple_debug_error("jabber", "XML parser error for JabberStream %p: " |
24471
e2f5a4a091b5
Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <mark@kingant.net>
parents:
23954
diff
changeset
|
208 "Domain %i, code %i, level %i: %s", |
23424
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
209 js, |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
210 error->domain, error->code, error->level, |
24474
8de8ca65e1d9
I know Mark was trying to save newlines, but I had one to spare.
Richard Laager <rlaager@wiktel.com>
parents:
24471
diff
changeset
|
211 (error->message ? error->message : "(null)\n")); |
23424
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
212 } |
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
213 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 static xmlSAXHandler jabber_parser_libxml = { |
22912
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
215 NULL, /*internalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
216 NULL, /*isStandalone*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
217 NULL, /*hasInternalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
218 NULL, /*hasExternalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
219 NULL, /*resolveEntity*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
220 NULL, /*getEntity*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
221 NULL, /*entityDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
222 NULL, /*notationDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
223 NULL, /*attributeDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
224 NULL, /*elementDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
225 NULL, /*unparsedEntityDecl*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
226 NULL, /*setDocumentLocator*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
227 NULL, /*startDocument*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
228 NULL, /*endDocument*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
229 NULL, /*startElement*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
230 NULL, /*endElement*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
231 NULL, /*reference*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
232 jabber_parser_element_text_libxml, /*characters*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
233 NULL, /*ignorableWhitespace*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
234 NULL, /*processingInstruction*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
235 NULL, /*comment*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
236 NULL, /*warning*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
237 NULL, /*error*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
238 NULL, /*fatalError*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
239 NULL, /*getParameterEntity*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
240 NULL, /*cdataBlock*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
241 NULL, /*externalSubset*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
242 XML_SAX2_MAGIC, /*initialized*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
243 NULL, /*_private*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
244 jabber_parser_element_start_libxml, /*startElementNs*/ |
ada1640fa260
Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21358
diff
changeset
|
245 jabber_parser_element_end_libxml, /*endElementNs*/ |
23424
1b3aea146613
Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22912
diff
changeset
|
246 jabber_parser_structured_error_handler /*serror*/ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 jabber_parser_setup(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 /* This seems backwards, but it makes sense. The libxml code creates |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 * the parser context when you try to use it (this way, it can figure |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 * out the encoding at creation time. So, setting up the parser is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 * just a matter of destroying any current parser. */ |
17876
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
256 jabber_parser_free(js); |
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
257 } |
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
258 |
7a3a66c6530a
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
259 void jabber_parser_free(JabberStream *js) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 if (js->context) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 xmlParseChunk(js->context, NULL,0,1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 xmlFreeParserCtxt(js->context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 js->context = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 void jabber_parser_process(JabberStream *js, const char *buf, int len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 { |
23425
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23424
diff
changeset
|
269 int ret; |
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23424
diff
changeset
|
270 |
23427 | 271 if (js->context == NULL) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 /* libxml inconsistently starts parsing on creating the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 * parser, so do a ParseChunk right afterwards to force it. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 xmlParseChunk(js->context, "", 0, 0); |
23425
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23424
diff
changeset
|
276 } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) { |
23954
08c50482d5a2
Only disconnect xmpp connections during xml parsing if the error is an
Stu Tomlinson <stu@nosnilmot.com>
parents:
23427
diff
changeset
|
277 xmlError *err = xmlCtxtGetLastError(js->context); |
25586
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
278 /* |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
279 * libxml2 uses a global setting to determine whether or not to store |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
280 * warnings. Other libraries may set this, which causes err to be |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
281 * NULL. See #8136 for details. |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
282 */ |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
283 xmlErrorLevel level = XML_ERR_WARNING; |
23425
0eca6c183d60
xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evan.s@dreskin.net>
parents:
23424
diff
changeset
|
284 |
25586
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
285 if (err) |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
286 level = err->level; |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
287 |
f424f26dd329
*** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <paul@darkrain42.org>
parents:
25476
diff
changeset
|
288 switch (level) { |
24926
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
289 case XML_ERR_NONE: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
290 purple_debug_info("jabber", "xmlParseChunk returned info %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
291 break; |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
292 case XML_ERR_WARNING: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
293 purple_debug_warning("jabber", "xmlParseChunk returned warning %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
294 break; |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
295 case XML_ERR_ERROR: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
296 purple_debug_error("jabber", "xmlParseChunk returned error %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
297 break; |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
298 case XML_ERR_FATAL: |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
299 purple_debug_error("jabber", "xmlParseChunk returned fatal %i\n", ret); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
300 purple_connection_error_reason (js->gc, |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
301 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
302 _("XML Parse error")); |
ee9b00cc4298
Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <stu@nosnilmot.com>
parents:
24853
diff
changeset
|
303 break; |
23426
ce361cc8e43b
Drop and then recover from XML messages which trigger invalid character
Evan Schoenberg <evan.s@dreskin.net>
parents:
23425
diff
changeset
|
304 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 } |
28327
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
306 |
29561
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
307 if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 && |
618c4165d4f8
jabber: Treat the version properly.
Paul Aurich <paul@darkrain42.org>
parents:
29359
diff
changeset
|
308 !js->gc->disconnect_timeout && |
28327
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
309 (js->state == JABBER_STREAM_INITIALIZING || |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
310 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) { |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
311 /* |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
312 * Legacy servers don't advertise features, so if we've just gotten |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
313 * the opening <stream:stream> and there was no version, we need to |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
314 * immediately start legacy IQ auth. |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
315 */ |
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
316 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28327
diff
changeset
|
317 jabber_auth_start_old(js); |
28327
c7aaad89a2f8
jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
318 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 |