Skip to content

Colon in url path is not parsed by parse_url #12703

@vdauchy

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions