]> granicus.if.org Git - php/commitdiff
(PHP xml_parse_into_struct) sometimes the value was truncated
authorThies C. Arntzen <thies@php.net>
Wed, 20 Oct 1999 14:58:03 +0000 (14:58 +0000)
committerThies C. Arntzen <thies@php.net>
Wed, 20 Oct 1999 14:58:03 +0000 (14:58 +0000)
@- XML_Parse_Into_Struct no longer eats data. (Thies)

ext/xml/xml.c

index 66e1fe6dbbef934faffd46d525cb58488fe3661d..bfcc14b403bc1c75192ec159233e045f8f9670ba 100644 (file)
@@ -814,7 +814,19 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
                        }
                        if (doprint || (! parser->skipwhite)) {
                                if (parser->lastwasopen) {
-                                       add_assoc_string(*(parser->ctag),"value",decoded_value,0);
+                                       zval **myval;
+                                       
+                                       /* check if the current tag already has a value - if yes append to that! */
+                                       if (zend_hash_find((*parser->ctag)->value.ht,"value",sizeof("value"),(void **) &myval) == SUCCESS) {
+                                               int newlen = (*myval)->value.str.len + decoded_len;
+                                               (*myval)->value.str.val = erealloc((*myval)->value.str.val,newlen);
+                                               strcpy((*myval)->value.str.val + (*myval)->value.str.len,decoded_value);
+                                               (*myval)->value.str.len += decoded_len;
+                                               efree(decoded_value);
+                                       } else {
+                                               add_assoc_string(*(parser->ctag),"value",decoded_value,0);
+                                       }
+                                       
                                } else {
                                        zval *tag;
 
@@ -828,7 +840,7 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
                                        add_assoc_string(tag,"value",decoded_value,0);
                                        add_assoc_string(tag,"type","cdata",1);
                                        add_assoc_long(tag,"level",parser->level);
-                                       
+
                                        zend_hash_next_index_insert(parser->data->value.ht,&tag,sizeof(zval*),NULL);
                                }
                        } else {