Changeset 24245
- Timestamp:
- 07/04/2008 01:02:14 PM (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/adium-1.2/Utilities/dep-build-scripts/libpurple_jabber_parser_error_handler.diff
r24148 r24245 1 # 2 # old_revision [20e2add42a314b4914e798757eb2a69ac3b491d0] 3 # 4 # patch "libpurple/protocols/jabber/parser.c" 5 # from [6cecb079972daf216504b3dce358ca781c92c3d9] 6 # to [d66cc169b95ef6131b2369df7ca32a04ca475f49] 7 # 8 ============================================================ 9 --- libpurple/protocols/jabber/parser.c 6cecb079972daf216504b3dce358ca781c92c3d9 10 +++ libpurple/protocols/jabber/parser.c d66cc169b95ef6131b2369df7ca32a04ca475f49 1 --- libpurple/protocols/jabber/parser.c 2008-07-03 19:18:09.000000000 -0400 2 +++ libpurple/protocols/jabber/parser.c 2008-07-04 12:15:07.000000000 -0400 11 3 @@ -132,6 +132,18 @@ jabber_parser_element_text_libxml(void * 12 4 xmlnode_insert_data(js->current, (const char*) text, text_len); … … 27 19 static xmlSAXHandler jabber_parser_libxml = { 28 20 NULL, /*internalSubset*/ 29 NULL, /*isStandalone*/21 NULL, /*isStandalone*/ 30 22 @@ -164,7 +176,7 @@ static xmlSAXHandler jabber_parser_libxm 31 NULL, /*_private*/32 jabber_parser_element_start_libxml, /*startElementNs*/33 jabber_parser_element_end_libxml, /*endElementNs*/23 NULL, /*_private*/ 24 jabber_parser_element_start_libxml, /*startElementNs*/ 25 jabber_parser_element_end_libxml, /*endElementNs*/ 34 26 - NULL /*serror*/ 35 27 + jabber_parser_structured_error_handler /*serror*/ … … 37 29 38 30 void 39 @@ -179,6 +191, 7 @@ void jabber_parser_free(JabberStream *js31 @@ -179,6 +191,8 @@ jabber_parser_setup(JabberStream *js) 40 32 41 33 void jabber_parser_free(JabberStream *js) { 42 34 if (js->context) { 43 35 + xmlSetStructuredErrorFunc(NULL, jabber_parser_structured_error_handler); 36 + 44 37 xmlParseChunk(js->context, NULL,0,1); 45 38 xmlFreeParserCtxt(js->context); 46 39 js->context = NULL; 47 @@ -187, 6 +200,8 @@ void jabber_parser_process(JabberStream40 @@ -187,15 +201,27 @@ void jabber_parser_free(JabberStream *js 48 41 49 42 void jabber_parser_process(JabberStream *js, const char *buf, int len) 50 43 { 44 - if (js->context == NULL) { 45 + int ret; 46 + 51 47 + xmlSetStructuredErrorFunc(NULL, jabber_parser_structured_error_handler); 52 48 + 53 if (js->context ==NULL) {49 + if (js->context == NULL) { 54 50 /* libxml inconsistently starts parsing on creating the 55 51 * parser, so do a ParseChunk right afterwards to force it. */ 52 js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL); 53 xmlParseChunk(js->context, "", 0, 0); 54 - } else if (xmlParseChunk(js->context, buf, len, 0) < 0) { 55 - purple_connection_error_reason (js->gc, 56 - PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 57 - _("XML Parse error")); 58 + } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) { 59 + purple_debug_error("jabber", "xmlParseChunk returned error %i", ret); 60 + 61 + if ((ret >= XML_ERR_INVALID_HEX_CHARREF) && (ret <= XML_ERR_INVALID_CHAR)) { 62 + /* If the error involves an invalid character, just drop this message. 63 + * We'll create a new parser next time it's needed. */ 64 + jabber_parser_free(js); 65 + } else { 66 + purple_connection_error_reason (js->gc, 67 + PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 68 + _("XML Parse error")); 69 + } 70 } 71 } 72