8000 [HttpClient] URL with colon is not correctly parsed · Issue #58313 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpClient] URL with colon is not correctly parsed #58313

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
philipzeyen opened this issue Sep 19, 2024 · 6 comments
Closed

[HttpClient] URL with colon is not correctly parsed #58313

philipzeyen opened this issue Sep 19, 2024 · 6 comments

Comments

@philipzeyen
Copy link
philipzeyen commented Sep 19, 2024

Symfony version(s) affected

5.4

Description

The HttpClientTrait::parseUrl Method cannot parse Urls containing a colon correctly.
EDIT: Solution developed in #58218 does not fix this problem

How to reproduce

$client = new NativeHttpClient([ // this client can be replaced with others
    'base_uri' => 'https://host.tld/'
]);
$response = $client->request(Request::METHOD_DELETE, 'foo/bar:1/baz');
// throws following exception: 'Symfony\Component\HttpClient\Exception\TransportException: Could not resolve host "foo"'

Possible Solution

Adding the configured base_uri before calling PHPs parse_url

Additional Context

No response

@ajgarlag
Copy link
Contributor

Possible duplicate of #54332. See #58218 for the fix.

@philipzeyen
Copy link
Author

Hey @ajgarlag
i tried the solution developed in #58218. It does not fix this problem.
Have forgotten to mention it

@nicolas-grekas
Copy link
Member

parse_url() oddities, see how PHP understands this URL:
https://3v4l.org/appLK

This case could be added to php/php-src#12703

Add a / prefix if you can that'd work with #58218

@nicolas-grekas
Copy link
Member

Closed by #58218

@nicolas-grekas
Copy link
Member

Sorry, I meant this URL is just incompatible with parse_url in a too broken way. Use a / prefix instead.

@nicolas-grekas
Copy link
Member

Actually I figured out a workaround in #58836

nicolas-grekas added a commit that referenced this issue Nov 13, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

Work around `parse_url()` bug (bis)

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | #58313
| License       | MIT

This PR is a follow up of #58218

parse_url behaves incorrectly when parsing some URLs that don't contain `?` or `#`.
This PR ensures that one of those chars is always found when calling the function.

Commits
-------

80257ea Work around parse_url() bug (bis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0