-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fixed parse_url(): can not recognize port without scheme #7844
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://3v4l.org/RBvOW
It shows when we add the scheme, its behavior back to normal, so I think it is correct to have the same behavior in the non-scheme branch.
ext/standard/url.c
Outdated
@@ -154,6 +154,10 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port | |||
goto parse_port; | |||
} | |||
|
|||
if (*p == '?') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should fix it by this way on line 153:
if ((p == ue || *p == '/' || *p == '?') && (p - e) < 7) {
Thank you for the PR! I'm not against fixing this particular issue for partial URLs (although https://3v4l.org/vtrZb should probably fixed as well), but I consider it more important to have an URI parser which strictly conforms to the specification, and which doesn't even attempt to parse partial URIs (that would need to be another function for BC reasons, though). |
so you think we need create an URI parser to replace parse_url? @cmb69 |
Yes, I think we need a proper URI parser, but not to replace |
ok, i prepare to copy parse_url method code and change it for fix scheme , so how we name the method ? parse_uri? @cmb69 |
The name of the new function can still be decided later. But I wouldn't reuse the code in |
@cmb69 hello, How progress this pr? |
Thanks for the reminder! I have merged the PR after renaming and slightly tweaking the test case. |
This caused a regression in Drupal, where we support URL's that look like this: |
fixed Before
output
# fixed After
output