Adium

Changeset 24245

Show
Ignore:
Timestamp:
07/04/2008 01:02:14 PM (6 months ago)
Author:
evands
Message:

Patch now updates pidgin 2.4.3's parser.c to have current changes to handle parsing errors

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 
    113@@ -132,6 +132,18 @@ jabber_parser_element_text_libxml(void * 
    124        xmlnode_insert_data(js->current, (const char*) text, text_len); 
     
    2719 static xmlSAXHandler jabber_parser_libxml = { 
    2820        NULL,                                                                   /*internalSubset*/ 
    29       NULL,                                                                   /*isStandalone*/ 
     21      NULL,                                                                   /*isStandalone*/ 
    3022@@ -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*/ 
    3426-       NULL                                                                    /*serror*/ 
    3527+       jabber_parser_structured_error_handler  /*serror*/ 
     
    3729  
    3830 void 
    39 @@ -179,6 +191,7 @@ void jabber_parser_free(JabberStream *js 
     31@@ -179,6 +191,8 @@ jabber_parser_setup(JabberStream *js) 
    4032  
    4133 void jabber_parser_free(JabberStream *js) { 
    4234        if (js->context) { 
    4335+               xmlSetStructuredErrorFunc(NULL, jabber_parser_structured_error_handler); 
     36+ 
    4437                xmlParseChunk(js->context, NULL,0,1); 
    4538                xmlFreeParserCtxt(js->context); 
    4639                js->context = NULL; 
    47 @@ -187,6 +200,8 @@ void jabber_parser_process(JabberStream  
     40@@ -187,15 +201,27 @@ void jabber_parser_free(JabberStream *js 
    4841  
    4942 void jabber_parser_process(JabberStream *js, const char *buf, int len) 
    5043 { 
     44-       if (js->context ==  NULL) { 
     45+       int ret; 
     46+ 
    5147+       xmlSetStructuredErrorFunc(NULL, jabber_parser_structured_error_handler); 
    5248+ 
    53        if (js->context == NULL) { 
     49+      if (js->context == NULL) { 
    5450                /* libxml inconsistently starts parsing on creating the 
    5551                 * 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