Skip to content

Colon in url path is not parsed by parse_url #12703

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

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