Skip to content

Fix #80266: parse_url silently drops port number 0 #6399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Nov 4, 2020

As of commit 81b2f3e[1], parse_url() accepts URLs with a zero port,
but does not report that port, what is wrong in hindsight.

Since the port number is stored as unsigned short there is no way to
distinguish between port zero and no port. For BC reasons, we thus
introduce parse_url_ex2() which accepts an output parameter that
allows that distinction, and use the new function to fix the behavior.

The introduction of parse_url_ex2() has been suggested by Nikita.

[1] http://git.php.net/?p=php-src.git;a=commit;h=81b2f3e5d9fcdffd87a4fcd12bd8c708a97091e1

As of commit 81b2f3e[1], `parse_url()` accepts URLs with a zero port,
but does not report that port, what is wrong in hindsight.

Since the port number is stored as `unsigned short` there is no way to
distinguish between port zero and no port.  For BC reasons, we thus
introduce `parse_url_ex2()` which accepts an output parameter that
allows that distinction, and use the new function to fix the behavior.

The introduction of `parse_url_ex2()` has been suggested by Nikita.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=81b2f3e5d9fcdffd87a4fcd12bd8c708a97091e1>
@php-pulls php-pulls closed this in 2cab085 Nov 4, 2020
@cmb69 cmb69 deleted the cmb/80266 branch November 4, 2020 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants