Skip to content

Commit b331242

Browse files
committed
Add support for getting SKIP_TAGSTART and SKIP_WHITE options
When `XML_OPTION_SKIP_TAGSTART` and `XML_OPTION_SKIP_WHITE` had been introduced[1], it had been overlooked to also support them for `xml_parser_get_option()`. We catch up on that. [1] <http://git.php.net/?p=php-src.git;a=commit;h=b57dc275950b228f2399990471c4f22b7d154c6c>
1 parent 113213f commit b331242

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ PHP NEWS
2828

2929
- XML:
3030
. Fixed bug #30875 (xml_parse_into_struct() does not resolve entities). (cmb)
31+
. Add support for getting SKIP_TAGSTART and SKIP_WHITE options. (cmb)
3132

3233
11 Oct 2018, PHP 7.1.23
3334

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
xml_parser_get_option() with XML_OPTION_SKIP_TAGSTART and XML_OPTION_SKIP_WHITE
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xml')) die('skip xml extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$parser = xml_parser_create();
10+
echo "defaults:\n";
11+
var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_TAGSTART));
12+
var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_WHITE));
13+
echo "setting:\n";
14+
var_dump(xml_parser_set_option($parser, XML_OPTION_SKIP_TAGSTART, 7));
15+
var_dump(xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1));
16+
echo "getting:\n";
17+
var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_TAGSTART));
18+
var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_WHITE));
19+
?>
20+
--EXPECT--
21+
defaults:
22+
int(0)
23+
int(0)
24+
setting:
25+
bool(true)
26+
bool(true)
27+
getting:
28+
int(7)
29+
int(1)

ext/xml/xml.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,12 @@ PHP_FUNCTION(xml_parser_get_option)
16531653
case PHP_XML_OPTION_CASE_FOLDING:
16541654
RETURN_LONG(parser->case_folding);
16551655
break;
1656+
case PHP_XML_OPTION_SKIP_TAGSTART:
1657+
RETURN_LONG(parser->toffset);
1658+
break;
1659+
case PHP_XML_OPTION_SKIP_WHITE:
1660+
RETURN_LONG(parser->skipwhite);
1661+
break;
16561662
case PHP_XML_OPTION_TARGET_ENCODING:
16571663
RETURN_STRING((char *)parser->target_encoding);
16581664
break;

0 commit comments

Comments
 (0)