Description
The following code:
<?php
try {
new Uri\WhatWg\Url("https://user:pass@");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
Uri\WhatWg\Url::parse("https://user:pass@", null, $e);
var_dump($e);
Resulted in this output:
Uri\WhatWg\InvalidUrlException: The specified URI is malformed
array(2) {
[0]=>
object(Uri\WhatWg\UrlValidationError)#6 (3) {
["context"]=>
string(0) ""
["type"]=>
enum(Uri\WhatWg\UrlValidationErrorType::InvalidCredentials)
["failure"]=>
bool(false)
}
[1]=>
object(Uri\WhatWg\UrlValidationError)#7 (3) {
["context"]=>
string(1) "@"
["type"]=>
enum(Uri\WhatWg\UrlValidationErrorType::InvalidCredentials)
["failure"]=>
bool(false)
}
}
But I expected this output instead:
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (HostMissing)
array(2) {
[0]=>
object(Uri\WhatWg\UrlValidationError)#6 (3) {
["context"]=>
string(0) ""
["type"]=>
enum(Uri\WhatWg\UrlValidationErrorType::HostMissing)
["failure"]=>
bool(true)
}
[1]=>
object(Uri\WhatWg\UrlValidationError)#7 (3) {
["context"]=>
string(1) "@"
["type"]=>
enum(Uri\WhatWg\UrlValidationErrorType::InvalidCredentials)
["failure"]=>
bool(false)
}
}
The URL specification specifies the following fatal validation error type in step 2.2.1 of the authority state:
If atSignSeen is true and buffer is the empty string, host-missing validation error, return failure.
This is tested by the (incorrect) PHP test whatwg/parsing/host_error_empty2.phpt.
PHP Version
PHP 8.5.8 (cli) (built: Jul 1 2026 16:35:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.8, Copyright (c) Zend Technologies
with Zend OPcache v8.5.8, Copyright (c), by Zend Technologies
Operating System
Arch Linux
Description
The following code:
Resulted in this output:
But I expected this output instead:
The URL specification specifies the following fatal validation error type in step 2.2.1 of the authority state:
This is tested by the (incorrect) PHP test whatwg/parsing/host_error_empty2.phpt.
PHP Version
Operating System
Arch Linux