Skip to content

Fix GH-25019: Uri\Rfc3986\Uri rejects a port with leading zeros as out of range - #25026

Closed
lazerg wants to merge 2 commits into
php:PHP-8.5from
lazerg:fix/gh-25019-rfc3986-port-leading-zeros
Closed

lazerg wants to merge 2 commits into
php:PHP-8.5from
lazerg:fix/gh-25019-rfc3986-port-leading-zeros

Conversation

@lazerg

@lazerg lazerg commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

port_str_to_zend_long_checked() rejected any port longer than MAX_LENGTH_OF_LONG digits before looking at its value, so http://example.com:000000000000000000008080/ threw "The port is out of range" even though the port is 8080. RFC 3986 allows any number of digits, and Uri\WhatWg\Url already accepts it. The leading zeros are now skipped before the length check.

Fixes #25019

Comment thread ext/uri/tests/rfc3986/parsing/port_success_leading_zeros.phpt
@kocsismate

Copy link
Copy Markdown
Member

Applied as c95e572

@kocsismate kocsismate closed this Oct 30, 2026
@kocsismate

Copy link
Copy Markdown
Member

thank you for the fix!

kairosci pushed a commit to kairosci/php-src that referenced this pull request Oct 30, 2026
It happened during merging php#25026 to 8.5, because the same parameter wasn't const back then.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants