diff libpurple/xmlnode.c @ 25586:f424f26dd329

*** Plucked rev d34a1589 (darkrain42@pidgin.im): Feed a fake </stream:stream> to the XMPP parser to silence warnings. Upgrading to TLS and disconnecting should no longer emit 'Extra content at the end of the document' References #8830. *** Plucked rev ca9f6d5b (darkrain42@pidgin.im): Add xmlnode and bonjour structured error handlers. Various libraries may set global structured error handlers and libxml2 prefers those to a per-context normal error handler. This causes us to break badly. References #8830. *** Plucked rev 34f4897e (darkrain42@pidgin.im): xmlCtxtGetLastError may return NULL, especially with other misbehaving libraries in our address space. References #8136.
author Paul Aurich <paul@darkrain42.org>
date Wed, 29 Apr 2009 20:57:53 +0000
parents efde7e6ed5f2
children 01f1929d0936
line wrap: on
line diff
--- a/libpurple/xmlnode.c	Wed Apr 29 19:39:11 2009 +0000
+++ b/libpurple/xmlnode.c	Wed Apr 29 20:57:53 2009 +0000
@@ -665,6 +665,28 @@
 	purple_debug_error("xmlnode", "Error parsing xml file: %s", errmsg);
 }
 
+static void
+xmlnode_parser_structural_error_libxml(void *user_data, xmlErrorPtr error)
+{
+	struct _xmlnode_parser_data *xpd = user_data;
+
+	if (error && (error->level == XML_ERR_ERROR ||
+	              error->level == XML_ERR_FATAL)) {
+		xpd->error = TRUE;
+		purple_debug_error("xmlnode", "XML parser error for xmlnode %p: "
+		                   "Domain %i, code %i, level %i: %s",
+		                   user_data, error->domain, error->code, error->level,
+		                   error->message ? error->message : "(null)\n");
+	} else if (error)
+		purple_debug_warning("xmlnode", "XML parser error for xmlnode %p: "
+		                     "Domain %i, code %i, level %i: %s",
+		                     user_data, error->domain, error->code, error->level,
+		                     error->message ? error->message : "(null)\n");
+	else
+		purple_debug_warning("xmlnode", "XML parser error for xmlnode %p\n",
+		                     user_data);
+}
+
 static xmlSAXHandler xmlnode_parser_libxml = {
 	NULL, /* internalSubset */
 	NULL, /* isStandalone */
@@ -697,7 +719,7 @@
 	NULL, /* _private */
 	xmlnode_parser_element_start_libxml, /* startElementNs */
 	xmlnode_parser_element_end_libxml,   /* endElementNs   */
-	NULL, /* serror */
+	xmlnode_parser_structural_error_libxml, /* serror */
 };
 
 xmlnode *