Changeset 301

Show
Ignore:
Timestamp:
25/07/07 10:28:33 (16 months ago)
Author:
smoku
Message:

Reverted r301:302 changes. Let the parser be permissive. Refs #112

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/sx/callback.c

    r299 r301  
    2121#include "sx.h" 
    2222 
    23 /* check for unescaped predefined entities */ 
    24 int _sx_check_unescaped_entities(char *str, int len) { 
    25     char *c; 
    26     int ret = 0; 
    27  
    28     if(len > 0) str = strndup(str, len); 
    29  
    30     if(strchr(str, '<')) ret = 1; 
    31     if(strchr(str, '>')) ret = 1; 
    32     if(strchr(str, '\'')) ret = 1; 
    33     if(strchr(str, '"')) ret = 1; 
    34     if((c = strchr(str, '&')) 
    35          && strcmp("&lt;",c) && strcmp("&gt;",c) && strcmp("&amp;",c) 
    36          && strcmp("&apos;",c) && strcmp("&quot;",c)) ret = 1; 
    37  
    38     if(len > 0) free(str); 
    39     return ret; 
    40 } 
    41  
    4223/** primary expat callbacks */ 
    4324void _sx_element_start(void *arg, const char *name, const char **atts) { 
    4425    sx_t s = (sx_t) arg; 
    45     sx_error_t sxe; 
    4626    char buf[1024]; 
    4727    char *uri, *elem, *prefix; 
     
    11696        } 
    11797 
    118         if(_sx_check_unescaped_entities((char *) attr[1], -1)) { 
    119             _sx_gen_error(sxe, SX_ERR_STREAM, "Stream error", "Unescaped predefined entity"); 
    120             _sx_event(s, event_ERROR, (void *) &sxe); 
    121             _sx_error(s, stream_err_RESTRICTED_XML, NULL); 
    122             s->fail = 1; 
    123             return; 
    124         } 
    125  
    12698        /* add it */ 
    12799        nad_append_attr(s->nad, ns, elem, (char *) attr[1]); 
     
    153125void _sx_cdata(void *arg, const char *str, int len) { 
    154126    sx_t s = (sx_t) arg; 
    155     sx_error_t sxe; 
    156127 
    157128    if(s->fail) return; 
     
    160131    if(s->nad == NULL) 
    161132        return; 
    162  
    163     if(_sx_check_unescaped_entities((char *) str, len)) { 
    164         _sx_gen_error(sxe, SX_ERR_STREAM, "Stream error", "Unescaped predefined entity"); 
    165         _sx_event(s, event_ERROR, (void *) &sxe); 
    166         _sx_error(s, stream_err_RESTRICTED_XML, NULL); 
    167         s->fail = 1; 
    168         return; 
    169     } 
    170133 
    171134    /* go */