[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 30 Oct 2026 13:59:08 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143004@lists.php.net to get a copy of this message
Author: Máté Kocsis (kocsismate) Date: 2026-10-30T14:57:58+01:00 Commit: https://github.com/php/php-src/commit/44f04b6668407f5810302e9f75fa294fbebc58d7 Raw diff: https://github.com/php/php-src/commit/44f04b6668407f5810302e9f75fa294fbebc58d7.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix GH-25019: Uri\Rfc3986\Uri rejects a port with leading zeros as out of range Changed paths: A ext/uri/tests/rfc3986/parsing/port_success_leading_zeros.phpt A ext/uri/tests/rfc3986/parsing/port_success_leading_zeros_zero.phpt M ext/uri/uri_parser_rfc3986.c Diff: diff --git a/ext/uri/tests/rfc3986/parsing/port_success_leading_zeros.phpt b/ext/uri/tests/rfc3986/parsing/port_success_leading_zeros.phpt new file mode 100644 index 000000000000..e3578fdc56ca --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/port_success_leading_zeros.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - port - leading zeros +--FILE-- +<?php + +$uri = Uri\Rfc3986\Uri::parse("http://example.com:000000000000000000008080"); + +var_dump($uri); +var_dump($uri->toRawString()); +var_dump($uri->toString()); + +?> +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(4) "http" + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + string(11) "example.com" + ["port"]=> + int(8080) + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +string(43) "http://example.com:000000000000000000008080" +string(23) "http://example.com:8080" diff --git a/ext/uri/tests/rfc3986/parsing/port_success_leading_zeros_zero.phpt b/ext/uri/tests/rfc3986/parsing/port_success_leading_zeros_zero.phpt new file mode 100644 index 000000000000..75796ddb9c65 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/port_success_leading_zeros_zero.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - port - leading zeros - zero +--FILE-- +<?php + +$uri = Uri\Rfc3986\Uri::parse("http://example.com:000000000000000000000000"); + +var_dump($uri); +var_dump($uri->toRawString()); +var_dump($uri->toString()); + +?> +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(4) "http" + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + string(11) "example.com" + ["port"]=> + int(0) + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +string(43) "http://example.com:000000000000000000000000" +string(20) "http://example.com:0" diff --git a/ext/uri/uri_parser_rfc3986.c b/ext/uri/uri_parser_rfc3986.c index 1a936a273ede..75e45a8c4b50 100644 --- a/ext/uri/uri_parser_rfc3986.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -385,6 +385,11 @@ static zend_result php_uri_parser_rfc3986_host_write(void *uri, const zval *valu ZEND_ATTRIBUTE_NONNULL static zend_long port_str_to_zend_long_checked(const char *str, const size_t len) { + while (len > 1 && *str == '0') { + str++; + len--; + } + if (len > MAX_LENGTH_OF_LONG) { return -1; }

« previous php.cvs (#143004) next »