From: Pierre Joye Date: Wed, 3 Feb 2010 18:35:58 +0000 (+0000) Subject: - Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). X-Git-Tag: php-5.3.2RC2~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec64f4528292e4b90a4fd15b8149c08e0c8d3ff1;p=php - Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). --- diff --git a/NEWS b/NEWS index 9237acf291..b8416f1348 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS - Fixed bug #50632 (filter_input() does not return default value if the variable does not exist). (Ilia) +- Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect). (Pierrick) - Fixed bug #48590 (SoapClient does not honor max_redirects). (Sriram) - Fixed bug #48190 (Content-type parameter "boundary" is not case-insensitive in HTTP uploads). (Ilia) diff --git a/ext/xml/tests/bug50576.phpt b/ext/xml/tests/bug50576.phpt new file mode 100644 index 0000000000..fd3d0cbb4a --- /dev/null +++ b/ext/xml/tests/bug50576.phpt @@ -0,0 +1,133 @@ +--TEST-- +Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect) +--SKIPIF-- + +--FILE-- + + + +867 + + +XML; + +$xml_parser = xml_parser_create(); +xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4); +xml_parse_into_struct($xml_parser, $XML, $vals, $index); +echo 'Index array' . PHP_EOL; +print_r($index); +echo 'Vals array' . PHP_EOL; +print_r($vals); +xml_parser_free($xml_parser); + +function startElement($parser, $name, $attribs) { echo $name . PHP_EOL; } +function endElement($parser, $name) { echo $name . PHP_EOL; } +$xml_parser = xml_parser_create(); +xml_set_element_handler($xml_parser, 'startElement', 'endElement'); +xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4); +xml_parse($xml_parser, $XML); +xml_parser_free($xml_parser); + +?> +--EXPECTF-- +Index array +Array +( + [LISTOFAWARDS] => Array + ( + [0] => 0 + [1] => 5 + [2] => 6 + ) + + [COUNT] => Array + ( + [0] => 1 + [1] => 3 + [2] => 4 + ) + + [TOTAL] => Array + ( + [0] => 2 + ) + +) +Vals array +Array +( + [0] => Array + ( + [tag] => LISTOFAWARDS + [type] => open + [level] => 1 + [attributes] => Array + ( + [XMLNS:NS1] => http://www.fpdsng.com/FPDS + ) + + [value] => + + ) + + [1] => Array + ( + [tag] => COUNT + [type] => open + [level] => 2 + [value] => + + ) + + [2] => Array + ( + [tag] => TOTAL + [type] => complete + [level] => 3 + [value] => 867 + ) + + [3] => Array + ( + [tag] => COUNT + [value] => + + [type] => cdata + [level] => 2 + ) + + [4] => Array + ( + [tag] => COUNT + [type] => close + [level] => 2 + ) + + [5] => Array + ( + [tag] => LISTOFAWARDS + [value] => + + [type] => cdata + [level] => 1 + ) + + [6] => Array + ( + [tag] => LISTOFAWARDS + [type] => close + [level] => 1 + ) + +) +LISTOFAWARDS +COUNT +TOTAL +TOTAL +COUNT +LISTOFAWARDS diff --git a/ext/xml/xml.c b/ext/xml/xml.c index c2c9457f2e..72729d6de5 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -804,7 +804,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch if (parser->startElementHandler) { args[0] = _xml_resource_zval(parser->index); - args[1] = _xml_string_zval(tag_name); + args[1] = _xml_string_zval(((char *) tag_name) + parser->toffset); MAKE_STD_ZVAL(args[2]); array_init(args[2]); @@ -884,7 +884,7 @@ void _xml_endElementHandler(void *userData, const XML_Char *name) if (parser->endElementHandler) { args[0] = _xml_resource_zval(parser->index); - args[1] = _xml_string_zval(tag_name); + args[1] = _xml_string_zval(((char *) tag_name) + parser->toffset); if ((retval = xml_call_handler(parser, parser->endElementHandler, parser->endElementPtr, 2, args))) { zval_ptr_dtor(&retval);