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
4 changes: 3 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,8 @@ xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, []);

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

xml_parser_set_option($xmlParser, XML_OPTION_SKIP_TAGSTART, "not numeric");

echo "Encodings\n";
try {
xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'Invalid Encoding');
Expand Down Expand Up @@ -75,7 +77,7 @@ Warning: xml_parser_set_option(): Argument #3 ($value) must be of type string|in

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

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 a valid integer for option XML_OPTION_SKIP_TAGSTART in %s on line %d
Encodings
xml_parser_set_option(): Argument #3 ($value) is not a supported target encoding

Expand Down
11 changes: 9 additions & 2 deletions ext/xml/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,8 +1588,15 @@ 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? */
zend_long value_long = zval_get_long(value);
bool failed = false;
zend_long value_long = zval_try_get_long(value, &failed);
if (failed) {
if (Z_TYPE_P(value) == IS_STRING) {
php_error_docref(NULL, E_WARNING,
"Argument #3 ($value) must be a valid integer for option XML_OPTION_SKIP_TAGSTART");
}
RETURN_FALSE;
}
if (value_long < 0 || value_long > INT_MAX) {
/* TODO Promote to ValueError in PHP 9.0 */
php_error_docref(NULL, E_WARNING, "Argument #3 ($value) must be between 0 and %d"
Expand Down
Loading