Skip to content

[Fix] parse_url: don’t treat colon in path as port #19527 #19528

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

arshidkv12
Copy link

Fix parse_url() to avoid treating a colon followed by digits inside the path as a port number.

Before:

$url = '//www.example.com/ddd:65333/';
var_export(parse_url($url));
array (
  'host' => 'www.example.com',
  'port' => 65333,
  'path' => '/ddd:65333/',
)

After

array (
  'host' => 'www.example.com',
  'path' => '/ddd:65333/',
)

@arshidkv12
Copy link
Author

#7890

@iluuu1994
Copy link
Member

Hi @arshidkv12. Did you follow the discussion in GH-7890? We can't adjust the parsing for invalid URLs due to backwards compatibility concerns. See https://wiki.php.net/rfc/url_parsing_api for the new URL parsing API that will be available in 8.5.

@arshidkv12
Copy link
Author

@iluuu1994 Sorry, I hadn’t checked that. Thanks for pointing it out! I’ll review the new URL parsing API in PHP 8.5.

@iluuu1994
Copy link
Member

No worries, thanks for getting back to me. And let us know if you find any issues with the new API.

@iluuu1994 iluuu1994 closed this Aug 20, 2025
@arshidkv12
Copy link
Author

Thanks! I’ll keep an eye out and let you know if anything comes up.

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.

2 participants