summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierrick Charron <pierrick@php.net>2010-01-05 13:03:40 +0000
committerPierrick Charron <pierrick@php.net>2010-01-05 13:03:40 +0000
commit0d44abd524953a79f8974867ef72d649b659e0ed (patch)
tree53dac50436c30b900bb84c78e3a074e64f0e2cb3
parentb1c8b9f48bd8397612a02fff38aa0343624d2b62 (diff)
downloadphp-git-0d44abd524953a79f8974867ef72d649b659e0ed.tar.gz
Fixed bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect).
-rw-r--r--NEWS1
-rw-r--r--ext/xml/tests/bug50576.phpt133
-rw-r--r--ext/xml/xml.c4
3 files changed, 136 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 16cbfcfa9f..379b3fa6f7 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ PHP NEWS
(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)
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--
+<?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
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 380fa95289..c12f6f8161 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -699,7 +699,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]);
@@ -779,7 +779,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);