Mercurial > pidgin.yaz
diff libpurple/protocols/jabber/parser.c @ 23986:1de1494a13e5
propagate from branch 'im.pidgin.pidgin' (head e685599ddcc769d157547685b5498df0662de8a2)
to branch 'im.pidgin.xmpp.custom_smiley' (head 110555eba89887adcf842166213ffc82770c0ee4)
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 04 Sep 2008 21:27:33 +0000 |
parents | 08c50482d5a2 |
children | e2f5a4a091b5 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/parser.c Wed Jun 11 15:20:16 2008 +0000 +++ b/libpurple/protocols/jabber/parser.c Thu Sep 04 21:27:33 2008 +0000 @@ -132,6 +132,18 @@ xmlnode_insert_data(js->current, (const char*) text, text_len); } +static void +jabber_parser_structured_error_handler(void *user_data, xmlErrorPtr error) +{ + JabberStream *js = user_data; + + purple_debug_error("jabber", "XML parser error for JabberStream %p: " + "Domain %i, code %i, level %i: %s\n", + js, + error->domain, error->code, error->level, + (error->message ? error->message : "(null)")); +} + static xmlSAXHandler jabber_parser_libxml = { NULL, /*internalSubset*/ NULL, /*isStandalone*/ @@ -164,7 +176,7 @@ NULL, /*_private*/ jabber_parser_element_start_libxml, /*startElementNs*/ jabber_parser_element_end_libxml, /*endElementNs*/ - NULL /*serror*/ + jabber_parser_structured_error_handler /*serror*/ }; void @@ -187,15 +199,23 @@ void jabber_parser_process(JabberStream *js, const char *buf, int len) { - if (js->context == NULL) { + int ret; + + if (js->context == NULL) { /* libxml inconsistently starts parsing on creating the * parser, so do a ParseChunk right afterwards to force it. */ js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL); xmlParseChunk(js->context, "", 0, 0); - } else if (xmlParseChunk(js->context, buf, len, 0) < 0) { - purple_connection_error_reason (js->gc, - PURPLE_CONNECTION_ERROR_NETWORK_ERROR, - _("XML Parse error")); + } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) { + xmlError *err = xmlCtxtGetLastError(js->context); + + purple_debug_error("jabber", "xmlParseChunk returned error %i\n", ret); + + if (err->level == XML_ERR_FATAL) { + purple_connection_error_reason (js->gc, + PURPLE_CONNECTION_ERROR_NETWORK_ERROR, + _("XML Parse error")); + } } }