Skip to content

Colon in url path is not parsed by parse_url #12703

Closed as not planned
Closed as not planned

Description

@vdauchy

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

Activity

  1. nicolas-grekas commented on Sep 10, 2024

    @nicolas-grekas
    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 :)

  2. added a commit that references this issue on Sep 11, 2024
  3. added 2 commits that reference this issue on Apr 10, 2026
    62b73ec
    854136f
  4. TimWolla commented on Apr 11, 2026

    @TimWolla
    Member

    Please migrate to the new ext/uri classes (Uri\* namespace) instead. See also php/doc-en#5477.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions