pierrick Tue, 05 Jan 2010 13:03:40 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=293146
Log:
Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect).
Bug: http://bugs.php.net/50576 (Verified) XML_OPTION_SKIP_TAGSTART option has
no effect
Changed paths:
U php/php-src/branches/PHP_5_2/NEWS
A php/php-src/branches/PHP_5_2/ext/xml/tests/bug50576.phpt
U php/php-src/branches/PHP_5_2/ext/xml/xml.c
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/ext/xml/tests/bug50576.phpt
U php/php-src/branches/PHP_5_3/ext/xml/xml.c
A php/php-src/trunk/ext/xml/tests/bug50576.phpt
U php/php-src/trunk/ext/xml/xml.c
Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS 2010-01-05 12:45:53 UTC (rev 293145)
+++ php/php-src/branches/PHP_5_2/NEWS 2010-01-05 13:03:40 UTC (rev 293146)
@@ -15,6 +15,7 @@
(Pierrick)
- 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 #50575 (PDO_PGSQL LOBs are not compatible with PostgreSQL 8.5).
(Matteo)
- Fixed bug #50558 (Broken object model when extending tidy). (Pierrick)
Added: php/php-src/branches/PHP_5_2/ext/xml/tests/bug50576.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/xml/tests/bug50576.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/xml/tests/bug50576.phpt 2010-01-05 13:03:40 UTC (rev 293146)
@@ -0,0 +1,133 @@
+--TEST--
+Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+
+$XML = <<<XML
+<?xml version="1.0"?>
+<ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS">
+<ns1:count>
+<ns1:total>867</ns1:total>
+</ns1:count>
+</ns1:listOfAwards>
+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
Modified: php/php-src/branches/PHP_5_2/ext/xml/xml.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/xml/xml.c 2010-01-05 12:45:53 UTC (rev 293145)
+++ php/php-src/branches/PHP_5_2/ext/xml/xml.c 2010-01-05 13:03:40 UTC (rev 293146)
@@ -699,7 +699,7 @@
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]);
@@ -779,7 +779,7 @@
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);
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-01-05 12:45:53 UTC (rev 293145)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-01-05 13:03:40 UTC (rev 293146)
@@ -12,6 +12,7 @@
(Pierrick)
- 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)
Added: php/php-src/branches/PHP_5_3/ext/xml/tests/bug50576.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/xml/tests/bug50576.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/xml/tests/bug50576.phpt 2010-01-05 13:03:40 UTC (rev 293146)
@@ -0,0 +1,133 @@
+--TEST--
+Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+
+$XML = <<<XML
+<?xml version="1.0"?>
+<ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS">
+<ns1:count>
+<ns1:total>867</ns1:total>
+</ns1:count>
+</ns1:listOfAwards>
+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
Modified: php/php-src/branches/PHP_5_3/ext/xml/xml.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/xml/xml.c 2010-01-05 12:45:53 UTC (rev 293145)
+++ php/php-src/branches/PHP_5_3/ext/xml/xml.c 2010-01-05 13:03:40 UTC (rev 293146)
@@ -804,7 +804,7 @@
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 @@
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);
Added: php/php-src/trunk/ext/xml/tests/bug50576.phpt
===================================================================
--- php/php-src/trunk/ext/xml/tests/bug50576.phpt (rev 0)
+++ php/php-src/trunk/ext/xml/tests/bug50576.phpt 2010-01-05 13:03:40 UTC (rev 293146)
@@ -0,0 +1,133 @@
+--TEST--
+Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+
+$XML = <<<XML
+<?xml version="1.0"?>
+<ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS">
+<ns1:count>
+<ns1:total>867</ns1:total>
+</ns1:count>
+</ns1:listOfAwards>
+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
Modified: php/php-src/trunk/ext/xml/xml.c
===================================================================
--- php/php-src/trunk/ext/xml/xml.c 2010-01-05 12:45:53 UTC (rev 293145)
+++ php/php-src/trunk/ext/xml/xml.c 2010-01-05 13:03:40 UTC (rev 293146)
@@ -815,7 +815,7 @@
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]);
@@ -897,7 +897,7 @@
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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php