pidgin: ca9f6d5b: Add xmlnode and bonjour structured error...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sat Apr 25 21:50:47 EDT 2009
-----------------------------------------------------------------
Revision: ca9f6d5b44c825689a68f91153d542205a39adf5
Ancestor: d34a15898cacf017df9190ca02741880be8dd940
Author: darkrain42 at pidgin.im
Date: 2009-04-26T00:30:02
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ca9f6d5b44c825689a68f91153d542205a39adf5
Modified files:
libpurple/protocols/bonjour/parser.c libpurple/xmlnode.c
ChangeLog:
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.
-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/parser.c cf14ad63b56a7e6ff3693c09ee81e1cbe5802555
+++ libpurple/protocols/bonjour/parser.c 92eb6a9fce3b1c5818b396694d9c787ea6fae5c4
@@ -153,6 +153,18 @@ bonjour_parser_element_text_libxml(void
xmlnode_insert_data(bconv->current, (const char*) text, text_len);
}
+static void
+bonjour_parser_structured_error_handler(void *user_data, xmlErrorPtr error)
+{
+ BonjourJabberConversation *bconv = user_data;
+
+ purple_debug_error("jabber", "XML parser error for BonjourJabberConversation %p: "
+ "Domain %i, code %i, level %i: %s",
+ bconv,
+ error->domain, error->code, error->level,
+ (error->message ? error->message : "(null)\n"));
+}
+
static xmlSAXHandler bonjour_parser_libxml = {
NULL, /*internalSubset*/
NULL, /*isStandalone*/
@@ -185,7 +197,7 @@ static xmlSAXHandler bonjour_parser_libx
NULL, /*_private*/
bonjour_parser_element_start_libxml, /*startElementNs*/
bonjour_parser_element_end_libxml, /*endElementNs*/
- NULL /*serror*/
+ bonjour_parser_structured_error_handler /*serror*/
};
void
============================================================
--- libpurple/xmlnode.c ce0a5a97c743a79e22eee920e950676f1438f171
+++ libpurple/xmlnode.c ff037d9a540b18e1b48a43022e3cc6deb4055685
@@ -647,6 +647,28 @@ xmlnode_parser_error_libxml(void *user_d
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 */
@@ -679,7 +701,7 @@ static xmlSAXHandler xmlnode_parser_libx
NULL, /* _private */
xmlnode_parser_element_start_libxml, /* startElementNs */
xmlnode_parser_element_end_libxml, /* endElementNs */
- NULL, /* serror */
+ xmlnode_parser_structural_error_libxml, /* serror */
};
xmlnode *
More information about the Commits
mailing list