libpurple/protocols/jabber/parser.c

Mon, 30 Nov 2009 02:40:30 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Mon, 30 Nov 2009 02:40:30 +0000
changeset 29025
2fdb2a69fb66
parent 28986
57ed606f526d
child 29026
72f3f28da29c
child 29057
a8de6baeee63
permissions
-rw-r--r--

Use g_str_equal()

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15698
diff changeset
2 * purple - Jabber XML parser stuff
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
6 * source distribution.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 15884
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
25 #include <libxml/parser.h>
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
26
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "connection.h"
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
28 #include "debug.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "jabber.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "parser.h"
15159
1acf4d03f878 [gaim-migrate @ 17883]
Nathan Walp <nwalp@pidgin.im>
parents: 15158
diff changeset
31 #include "util.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "xmlnode.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
34 static void
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
35 jabber_parser_element_start_libxml(void *user_data,
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
36 const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace,
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
37 int nb_namespaces, const xmlChar **namespaces,
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
38 int nb_attributes, int nb_defaulted, const xmlChar **attributes)
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
39 {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
40 JabberStream *js = user_data;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
41 xmlnode *node;
25288
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
42 int i, j;
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
43
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
44 if(!element_name) {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
45 return;
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
46 } else if(!xmlStrcmp(element_name, (xmlChar*) "stream")) {
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
47 js->protocol_version = JABBER_PROTO_0_9;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
48 for(i=0; i < nb_attributes * 5; i += 5) {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
49 int attrib_len = attributes[i+4] - attributes[i+3];
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
50 char *attrib = g_malloc(attrib_len + 1);
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
51 memcpy(attrib, attributes[i+3], attrib_len);
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
52 attrib[attrib_len] = '\0';
14498
ede839a78714 [gaim-migrate @ 17150]
Mark Doliner <markdoliner@pidgin.im>
parents: 14476
diff changeset
53
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
54 if(!xmlStrcmp(attributes[i], (xmlChar*) "version")
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
55 && !strcmp(attrib, "1.0")) {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
56 js->protocol_version = JABBER_PROTO_1_0;
14685
7622a9ca1794 [gaim-migrate @ 17352]
Daniel Atallah <datallah@pidgin.im>
parents: 14538
diff changeset
57 g_free(attrib);
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
58 } else if(!xmlStrcmp(attributes[i], (xmlChar*) "id")) {
15698
bcec3cb58d30 Patch from MatsMattsson (Adium Trac #6429) which fixes a leak of attrib for any attribute that isn't 'id' or 'version'.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
59 g_free(js->stream_id);
14685
7622a9ca1794 [gaim-migrate @ 17352]
Daniel Atallah <datallah@pidgin.im>
parents: 14538
diff changeset
60 js->stream_id = attrib;
15698
bcec3cb58d30 Patch from MatsMattsson (Adium Trac #6429) which fixes a leak of attrib for any attribute that isn't 'id' or 'version'.
Evan Schoenberg <evands@pidgin.im>
parents: 15558
diff changeset
61 } else {
25288
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
62 g_free(attrib);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
63 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
64 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
65 } else {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
66
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
67 if(js->current)
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
68 node = xmlnode_new_child(js->current, (const char*) element_name);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
69 else
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
70 node = xmlnode_new((const char*) element_name);
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
71 xmlnode_set_namespace(node, (const char*) namespace);
25288
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
72 xmlnode_set_prefix(node, (const char *)prefix);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
73
25288
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
74 if (nb_namespaces != 0) {
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
75 node->namespace_map = g_hash_table_new_full(
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
76 g_str_hash, g_str_equal, g_free, g_free);
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
77
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
78 for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
79 const char *key = (const char *)namespaces[j];
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
80 const char *val = (const char *)namespaces[j + 1];
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
81 g_hash_table_insert(node->namespace_map,
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
82 g_strdup(key ? key : ""), g_strdup(val ? val : ""));
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
83 }
2cd805f52348 Don't ignore XML namespace and prefix information when parsing incoming XMPP
Michal Witkowski <neuro@o2.pl>
parents: 24738
diff changeset
84 }
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
85 for(i=0; i < nb_attributes * 5; i+=5) {
26393
7420fd99903a Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25620
diff changeset
86 const char *name = (const char *)attributes[i];
7420fd99903a Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25620
diff changeset
87 const char *prefix = (const char *)attributes[i+1];
25620
fb9118dea0ed Don't set an attribute prefix on the node, and remove an unnecessary call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25365
diff changeset
88 const char *attrib_ns = (const char *)attributes[i+2];
15158
501a55683bf2 [gaim-migrate @ 17882]
Nathan Walp <nwalp@pidgin.im>
parents: 14700
diff changeset
89 char *txt;
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
90 int attrib_len = attributes[i+4] - attributes[i+3];
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
91 char *attrib = g_malloc(attrib_len + 1);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15159
diff changeset
92
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
93 memcpy(attrib, attributes[i+3], attrib_len);
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
94 attrib[attrib_len] = '\0';
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15159
diff changeset
95
15158
501a55683bf2 [gaim-migrate @ 17882]
Nathan Walp <nwalp@pidgin.im>
parents: 14700
diff changeset
96 txt = attrib;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15698
diff changeset
97 attrib = purple_unescape_html(txt);
15158
501a55683bf2 [gaim-migrate @ 17882]
Nathan Walp <nwalp@pidgin.im>
parents: 14700
diff changeset
98 g_free(txt);
26393
7420fd99903a Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25620
diff changeset
99 xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
100 g_free(attrib);
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
101 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
102
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
103 js->current = node;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
104 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
105 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
106
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
107 static void
14498
ede839a78714 [gaim-migrate @ 17150]
Mark Doliner <markdoliner@pidgin.im>
parents: 14476
diff changeset
108 jabber_parser_element_end_libxml(void *user_data, const xmlChar *element_name,
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
109 const xmlChar *prefix, const xmlChar *namespace)
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
110 {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
111 JabberStream *js = user_data;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
112
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
113 if(!js->current)
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
114 return;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
115
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
116 if(js->current->parent) {
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
117 if(!xmlStrcmp((xmlChar*) js->current->name, element_name))
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
118 js->current = js->current->parent;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
119 } else {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
120 xmlnode *packet = js->current;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
121 js->current = NULL;
17828
6957bf9d7330 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 <am@adiumx.com>
parents: 17813
diff changeset
122 jabber_process_packet(js, &packet);
24738
b642b5aa2a42 Don't try to free NULL xmlnodes stolen by jabber-receiving-xmlnode handlers
Will Thompson <resiak@pidgin.im>
parents: 24706
diff changeset
123 if (packet != NULL)
b642b5aa2a42 Don't try to free NULL xmlnodes stolen by jabber-receiving-xmlnode handlers
Will Thompson <resiak@pidgin.im>
parents: 24706
diff changeset
124 xmlnode_free(packet);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
125 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
126 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
127
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
128 static void
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
129 jabber_parser_element_text_libxml(void *user_data, const xmlChar *text, int text_len)
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
130 {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
131 JabberStream *js = user_data;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
132
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
133 if(!js->current)
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
134 return;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
135
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
136 if(!text || !text_len)
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
137 return;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
138
14690
9287ecc4adb1 [gaim-migrate @ 17369]
Daniel Atallah <datallah@pidgin.im>
parents: 14685
diff changeset
139 xmlnode_insert_data(js->current, (const char*) text, text_len);
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
140 }
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
141
23567
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
142 static void
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
143 jabber_parser_structured_error_handler(void *user_data, xmlErrorPtr error)
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
144 {
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
145 JabberStream *js = user_data;
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
146
24703
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
147 if (error->level == XML_ERR_WARNING && error->message != NULL
29025
2fdb2a69fb66 Use g_str_equal()
Paul Aurich <darkrain42@pidgin.im>
parents: 28986
diff changeset
148 && g_str_equal(error->message, "xmlns: URI vcard-temp is not absolute\n"))
24703
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
149 /*
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
150 * This message happens when parsing vcards, and is normal, so don't
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
151 * bother logging it because people scare easily.
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
152 */
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
153 return;
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
154
28986
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
155 if (error->level == XML_ERR_FATAL && error->message != NULL
29025
2fdb2a69fb66 Use g_str_equal()
Paul Aurich <darkrain42@pidgin.im>
parents: 28986
diff changeset
156 && g_str_equal(error->message, "Extra content at the end of the document\n"))
28986
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
157 /*
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
158 * This is probably more annoying than the vcard-temp error; it occurs
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
159 * because we disconnect in most cases without waiting for the receiving
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
160 * </stream:stream> (limitations of libpurple)
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
161 */
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
162 return;
57ed606f526d jabber: Don't print "Extra content at the end of the document".
Paul Aurich <darkrain42@pidgin.im>
parents: 28623
diff changeset
163
23567
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
164 purple_debug_error("jabber", "XML parser error for JabberStream %p: "
24703
26998f3425f7 Don't log an error when parsing vcard data. Also, these messages
Mark Doliner <markdoliner@pidgin.im>
parents: 24149
diff changeset
165 "Domain %i, code %i, level %i: %s",
23567
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
166 js,
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
167 error->domain, error->code, error->level,
24706
9fbd313398fe I know Mark was trying to save newlines, but I had one to spare.
Richard Laager <rlaager@pidgin.im>
parents: 24703
diff changeset
168 (error->message ? error->message : "(null)\n"));
23567
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
169 }
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
170
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
171 static xmlSAXHandler jabber_parser_libxml = {
23077
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
172 NULL, /*internalSubset*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
173 NULL, /*isStandalone*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
174 NULL, /*hasInternalSubset*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
175 NULL, /*hasExternalSubset*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
176 NULL, /*resolveEntity*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
177 NULL, /*getEntity*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
178 NULL, /*entityDecl*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
179 NULL, /*notationDecl*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
180 NULL, /*attributeDecl*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
181 NULL, /*elementDecl*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
182 NULL, /*unparsedEntityDecl*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
183 NULL, /*setDocumentLocator*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
184 NULL, /*startDocument*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
185 NULL, /*endDocument*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
186 NULL, /*startElement*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
187 NULL, /*endElement*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
188 NULL, /*reference*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
189 jabber_parser_element_text_libxml, /*characters*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
190 NULL, /*ignorableWhitespace*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
191 NULL, /*processingInstruction*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
192 NULL, /*comment*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
193 NULL, /*warning*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
194 NULL, /*error*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
195 NULL, /*fatalError*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
196 NULL, /*getParameterEntity*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
197 NULL, /*cdataBlock*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
198 NULL, /*externalSubset*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
199 XML_SAX2_MAGIC, /*initialized*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
200 NULL, /*_private*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
201 jabber_parser_element_start_libxml, /*startElementNs*/
431e35debb40 Using named elements in a struct initialization doesn't work in MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 21279
diff changeset
202 jabber_parser_element_end_libxml, /*endElementNs*/
23567
9189d89be26f Added a structured error handler callback to the xmlSAXHandler struct.
Evan Schoenberg <evands@pidgin.im>
parents: 23077
diff changeset
203 jabber_parser_structured_error_handler /*serror*/
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
204 };
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 void
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 jabber_parser_setup(JabberStream *js)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 {
14538
ada84c622f39 [gaim-migrate @ 17194]
Etan Reisner <deryni@pidgin.im>
parents: 14498
diff changeset
209 /* This seems backwards, but it makes sense. The libxml code creates
ada84c622f39 [gaim-migrate @ 17194]
Etan Reisner <deryni@pidgin.im>
parents: 14498
diff changeset
210 * the parser context when you try to use it (this way, it can figure
ada84c622f39 [gaim-migrate @ 17194]
Etan Reisner <deryni@pidgin.im>
parents: 14498
diff changeset
211 * out the encoding at creation time. So, setting up the parser is
ada84c622f39 [gaim-migrate @ 17194]
Etan Reisner <deryni@pidgin.im>
parents: 14498
diff changeset
212 * just a matter of destroying any current parser. */
17810
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
213 jabber_parser_free(js);
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
214 }
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
215
c8d4297080cb Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
216 void jabber_parser_free(JabberStream *js) {
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
217 if (js->context) {
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
218 xmlParseChunk(js->context, NULL,0,1);
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
219 xmlFreeParserCtxt(js->context);
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
220 js->context = NULL;
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
221 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
222 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224 void jabber_parser_process(JabberStream *js, const char *buf, int len)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 {
23568
bd3e623fa265 xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evands@pidgin.im>
parents: 23567
diff changeset
226 int ret;
bd3e623fa265 xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evands@pidgin.im>
parents: 23567
diff changeset
227
23570
5990199050f5 Whitespace fix
Evan Schoenberg <evands@pidgin.im>
parents: 23569
diff changeset
228 if (js->context == NULL) {
14538
ada84c622f39 [gaim-migrate @ 17194]
Etan Reisner <deryni@pidgin.im>
parents: 14498
diff changeset
229 /* libxml inconsistently starts parsing on creating the
ada84c622f39 [gaim-migrate @ 17194]
Etan Reisner <deryni@pidgin.im>
parents: 14498
diff changeset
230 * parser, so do a ParseChunk right afterwards to force it. */
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
231 js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL);
14700
98dc3d9a69e3 [gaim-migrate @ 17384]
Sean Egan <seanegan@pidgin.im>
parents: 14690
diff changeset
232 xmlParseChunk(js->context, "", 0, 0);
23568
bd3e623fa265 xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evands@pidgin.im>
parents: 23567
diff changeset
233 } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) {
24149
7ee629835390 Only disconnect xmpp connections during xml parsing if the error is an
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23570
diff changeset
234 xmlError *err = xmlCtxtGetLastError(js->context);
25726
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
235 /*
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
236 * libxml2 uses a global setting to determine whether or not to store
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
237 * warnings. Other libraries may set this, which causes err to be
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
238 * NULL. See #8136 for details.
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
239 */
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
240 xmlErrorLevel level = XML_ERR_WARNING;
23568
bd3e623fa265 xmlParseChunk() never returns less than 0. It retusn an error code from
Evan Schoenberg <evands@pidgin.im>
parents: 23567
diff changeset
241
25726
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
242 if (err)
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
243 level = err->level;
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
244
19e0c9302a43 *** Plucked rev d34a1589 (darkrain42@pidgin.im):
Paul Aurich <darkrain42@pidgin.im>
parents: 25620
diff changeset
245 switch (level) {
25365
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
246 case XML_ERR_NONE:
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
247 purple_debug_info("jabber", "xmlParseChunk returned info %i\n", ret);
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
248 break;
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
249 case XML_ERR_WARNING:
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
250 purple_debug_warning("jabber", "xmlParseChunk returned warning %i\n", ret);
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
251 break;
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
252 case XML_ERR_ERROR:
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
253 purple_debug_error("jabber", "xmlParseChunk returned error %i\n", ret);
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
254 break;
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
255 case XML_ERR_FATAL:
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
256 purple_debug_error("jabber", "xmlParseChunk returned fatal %i\n", ret);
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
257 purple_connection_error_reason (js->gc,
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
258 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
259 _("XML Parse error"));
e941a99c74b3 Make XML parsing error levels match libxml2's levels, making less important
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 25288
diff changeset
260 break;
23569
b76c41ef45d4 Drop and then recover from XML messages which trigger invalid character
Evan Schoenberg <evands@pidgin.im>
parents: 23568
diff changeset
261 }
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8296
diff changeset
262 }
28623
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
263
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
264 if (js->protocol_version == JABBER_PROTO_0_9 && !js->gc->disconnect_timeout &&
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
265 (js->state == JABBER_STREAM_INITIALIZING ||
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
266 js->state == JABBER_STREAM_INITIALIZING_ENCRYPTION)) {
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
267 /*
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
268 * Legacy servers don't advertise features, so if we've just gotten
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
269 * the opening <stream:stream> and there was no version, we need to
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
270 * immediately start legacy IQ auth.
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
271 */
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
272 js->auth_type = JABBER_AUTH_IQ_AUTH;
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
273 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
4f7f9d7bb23d jabber: Re-arrange the code that detects legacy servers so that we don't stomp over "Host Unknown" errors.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
274 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276

mercurial