Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ PHP NEWS
. Fixed bug #49874 (ftell() and fseek() inconsistency when using stream
filters). (Jakub Zelenka)

- XML:
. xml_parser_set_option() now reports invalid XML_OPTION_SKIP_TAGSTART
values more consistently and avoids an extra object-to-int conversion
warning for unsupported values. (Weilin Du)

- Zip:
. Fixed ZipArchive callback being called after executor has shut down.
(ilutov)
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ PHP 8.6 UPGRADE NOTES
. proc_open() now raises a ValueError when the $cwd argument contains
null bytes.

- XML:
. xml_parser_set_option() now reports invalid XML_OPTION_SKIP_TAGSTART
values more consistently and no longer emits an extra object-to-int
conversion warning for unsupported values.

- Zip:
. ZipArchive::extractTo now raises a TypeError for the
files argument if one or more of the entries is not
Expand Down
12 changes: 11 additions & 1 deletion ext/xml/tests/xml_parser_set_option_errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, []);

xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, new stdClass());

var_dump(xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, "123test"));
var_dump(xml_parser_get_option($xmlParser, XML_OPTION_SKIP_TAGSTART));

var_dump(xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, 1.5));
var_dump(xml_parser_get_option($xmlParser, XML_OPTION_SKIP_TAGSTART));

echo "Encodings\n";
try {
xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding');
Expand Down Expand Up @@ -74,8 +80,12 @@ Warning: xml_parser_set_option(): Argument #3 ($value) must be between 0 and 214
Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, array given in %s on line %d

Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, stdClass given in %s on line %d
bool(true)
int(123)

Warning: Object of class stdClass could not be converted to int in %s on line %d
Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|int|bool, float given in %s on line %d
bool(true)
int(1)
Encodings
xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a float test case (e.g. 1.5)? IS_DOUBLE now falls into the silent else and returns false, whereas before it would have been cast and accepted. Worth
pinning down in the phpt.

Expand Down
12 changes: 11 additions & 1 deletion ext/xml/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,17 @@ PHP_FUNCTION(xml_parser_set_option)
/* Integer option */
case PHP_XML_OPTION_SKIP_TAGSTART: {
/* The tag start offset is stored in an int */
/* TODO Improve handling of values? */
switch (Z_TYPE_P(value)) {
case IS_FALSE:
case IS_TRUE:
case IS_LONG:
case IS_DOUBLE:
case IS_STRING:
break;
default:
RETURN_FALSE;
}

zend_long value_long = zval_get_long(value);
if (value_long < 0 || value_long > INT_MAX) {
/* TODO Promote to ValueError in PHP 9.0 */
Expand Down
Loading