8000 Colon in url path is not parsed by `parse_url` · Issue #12703 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

Colon in url path is not parsed by parse_url #12703

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

Open
vdauchy opened this issue Nov 17, 2023 · 1 comment
Open

Colon in url path is not parsed by parse_url #12703

vdauchy opened this issue Nov 17, 2023 · 1 comment

Comments

@vdauchy
Copy link
vdauchy commented Nov 17, 2023

Description

parse_url() return false on absolute path containing : and no query string.

The following code:

<?php
var_dump(parse_url('/page:1?foo=bar'));  // Working example of parsing.

var_dump(parse_url('/page:1'));
var_dump(parse_url('/page:1', \PHP_URL_SCHEME));

Resulted in this output:

array(2) {
  ["path"]=>
  string(7) "/page:1"
  ["query"]=>
  string(7) "foo=bar"
}

bool(false)
bool(false)

But I expected this output instead:

array(2) {
  ["path"]=>
  string(7) "/page:1"
  ["query"]=>
  string(7) "foo=bar"
}

array(1) {
  ["path"]=>
  string(7) "/page:1"
}
NULL

This issue is opened following discussion on Symfony DomCrawler: symfony/symfony#52628

PHP Version

8.1.12

Operating System

No response

@nicolas-grekas
Copy link
Contributor

We should still fix this case IMHO. The engine currently fails to parse valid URLs.
I implemented a workaround in symfony/symfony#58218 but this is not pretty :)

nicolas-grekas added a commit to symfony/symfony that referenced this issue Sep 11, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

Work around `parse_url()` bug

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #52579, #54332
| License       | MIT

Works around
* php/php-src#12703

Commits
-------

fb76e53 Work around parse_url() bug
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

3 participants
0