Skip to content

parse_url() and incorrect port definition  #7890

Open
@MioVisman

Description

@MioVisman

Description

The following code:

<?php

$url = '//www.examle.com/ddd:65535/';

echo "<pre>\n";
var_export(parse_url($url));
echo "</pre>\n";

exit;

Resulted in this output:

array (
  'host' => 'www.examle.com',
  'port' => 65535,
  'path' => '/ddd:65535/',
)

But I expected this output instead:

array (
  'host' => 'www.examle.com',
  'path' => '/ddd:65535/',
)

If url starts with // and path ends with :{num}/, then:

  1. num = 0-65535 -> num gets into port and path
  2. num = 65536-99999 -> the function returns fasle instead of an array
  3. num < 0 or > 99999 -> all ok

P.S. https://www.php.net/manual/ru/function.parse-url.php#122207

PHP Version

PHP 8.1.1-Win32-vs16-x64, 7.3.33

Operating System

Windows 7 x64

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