[php-src] Issue #25019: ext/uri: Uri\Rfc3986\Uri rejects a port with leading zeros as out of range

From: Date: Wed, 28 Oct 2026 21:10:05 +0000
Subject: [php-src] Issue #25019: ext/uri: Uri\Rfc3986\Uri rejects a port with leading zeros as out of range
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-253904@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25019 Author: nicolas-grekas ### Description The following code: ```php <?php var_dump(new Uri\Rfc3986\Uri('http://example.com:000000000000000000008080/')->getPort()); ``` Resulted in this output: ``` PHP Fatal error: Uncaught Uri\InvalidUriException: The port is out of range ``` But I expected this output instead: ``` int(8080) ``` port_str_to_zend_long_checked() compares the number of digits with MAX_LENGTH_OF_LONG before skipping the leading zeros. So 20 digits work and 21 don't, whatever the value. RFC 3986 defines port = *DIGIT, and Uri\WhatWg\Url::parse() returns 8080 for the same URL. ### PHP Version ```plain PHP 8.5.10 (cli) (built: Aug 28 2026 06:46:18) (NTS) ``` The code is the same on the PHP-8.5 branch. ### Operating System Ubuntu 24.04 (WSL2)

« previous php.bugs (#253904) next »