1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Reorganize ext/uri tests - parsing (#20340)
This commit is contained in:
Máté Kocsis
2025-11-03 21:52:23 +01:00
88 changed files with 2079 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - multibyte character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("🐘");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - URI contains null byte
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://exam\0ple.com");
} catch (ValueError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: Uri\Rfc3986\Uri::__construct(): Argument #1 ($uri) must not contain any null bytes

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - URI contains null byte
--FILE--
<?php
try {
Uri\Rfc3986\Uri::parse("https://exam\0ple.com");
} catch (ValueError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: Uri\Rfc3986\Uri::parse(): Argument #1 ($uri) must not contain any null bytes

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - all components
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://user:info@example.com:443/foo/bar?abc=123&def=ghi#hashmark");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(4) "user"
["password"]=>
string(4) "info"
["host"]=>
string(11) "example.com"
["port"]=>
int(443)
["path"]=>
string(8) "/foo/bar"
["query"]=>
string(15) "abc=123&def=ghi"
["fragment"]=>
string(8) "hashmark"
}
string(66) "https://user:info@example.com:443/foo/bar?abc=123&def=ghi#hashmark"
string(66) "https://user:info@example.com:443/foo/bar?abc=123&def=ghi#hashmark"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - mailto email
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("mailto:user@example.com");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(6) "mailto"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(16) "user@example.com"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(23) "mailto:user@example.com"
string(23) "mailto:user@example.com"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - empty string
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
NULL
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(0) ""
string(0) ""

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - file
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("file:///E:/Documents%20and%20Settings");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(4) "file"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(0) ""
["port"]=>
NULL
["path"]=>
string(30) "/E:/Documents%20and%20Settings"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(37) "file:///E:/Documents%20and%20Settings"
string(37) "file:///E:/Documents%20and%20Settings"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - basic - URN
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(3) "urn"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(41) "uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(45) "urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"
string(45) "urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - multibyte character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://exḁmple.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - reserved character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://ex[a]mple.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - empty
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(0) ""
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(8) "https://"
string(8) "https://"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - empty
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://user:pass@");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(4) "user"
["password"]=>
string(4) "pass"
["host"]=>
string(0) ""
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(18) "https://user:pass@"
string(18) "https://user:pass@"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - empty
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("//");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
NULL
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(0) ""
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(2) "//"
string(2) "//"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - empty
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("///");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
NULL
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(0) ""
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(3) "///"
string(3) "///"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - IPv4
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://192.168.0.1");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "192.168.0.1"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(19) "https://192.168.0.1"
string(19) "https://192.168.0.1"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - wrong IPv4 format
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://192.168");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(7) "192.168"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(15) "https://192.168"
string(15) "https://192.168"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - IPv6
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://[2001:0db8:3333:4444:5555:6666:7777:8888]");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(41) "[2001:0db8:3333:4444:5555:6666:7777:8888]"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(49) "https://[2001:0db8:3333:4444:5555:6666:7777:8888]"
string(49) "https://[2001:0db8:3333:4444:5555:6666:7777:8888]"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - host - IPvFuture
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://[v7.host]");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(9) "[v7.host]"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(17) "https://[v7.host]"
string(17) "https://[v7.host]"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - path - multibyte character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://example.com/fȎȎ");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - path - reserved character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://example.com/fo[o/ba]r/");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - path - relative reference
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("foo");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
NULL
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(3) "foo"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(3) "foo"
string(3) "foo"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - path - relative reference
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("/foo");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
NULL
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(4) "/foo"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(4) "/foo"
string(4) "/foo"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - path - relative reference
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("?query#fragment");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
NULL
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
string(5) "query"
["fragment"]=>
string(8) "fragment"
}
string(15) "?query#fragment"
string(15) "?query#fragment"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - path - slash only
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("https://example.com/");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(20) "https://example.com/"
string(20) "https://example.com/"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - port - multibyte character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://example.com:Ȏ");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - port - negative value
--FILE--
<?php
try {
var_dump(new Uri\Rfc3986\Uri("http://example.com:-1"));
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - port - percent encoded character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("https://example.com:%30");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - port - user info component is in wrong place
--FILE--
<?php
try {
var_dump(new Uri\Rfc3986\Uri("https://example.com:8080@username:password"));
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - port - empty
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("http://example.com:");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(19) "http://example.com:"
string(19) "http://example.com:"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - port - zero
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("http://example.com:0");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
int(0)
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(20) "http://example.com:0"
string(20) "http://example.com:0"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - empty
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - multibyte characters
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("ƕŢŢƤƨ://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - percent encoded character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("http%2F://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - reserved character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("http&://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - empty host
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https:example.com");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(11) "example.com"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(17) "https:example.com"
string(17) "https:example.com"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - IANA scheme
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("chrome-extension://example.com");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(16) "chrome-extension"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(30) "chrome-extension://example.com"
string(30) "chrome-extension://example.com"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - only scheme
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("http:");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(5) "http:"
string(5) "http:"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - scheme - only scheme
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("http:/");
var_dump($uri);
var_dump($uri->toRawString());
var_dump($uri->toString());
?>
--EXPECTF--
object(Uri\Rfc3986\Uri)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(6) "http:/"
string(6) "http:/"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - userinfo - extended ASCII character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("http://úzör@example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - userinfo - multibyte character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("http://usĕr:pąss@example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\Rfc3986\Uri parsing - userinfo - reserved character
--FILE--
<?php
try {
new Uri\Rfc3986\Uri("http://us[er]:pass@example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - empty string
--FILE--
<?php
try {
new Uri\WhatWg\Url("");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - URL contains null byte
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://exam\0ple.com");
} catch (ValueError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: Uri\WhatWg\Url::__construct(): Argument #1 ($uri) must not contain any null bytes

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - URL contains null byte
--FILE--
<?php
try {
Uri\WhatWg\Url::parse("https://exam\0ple.com");
} catch (ValueError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: Uri\WhatWg\Url::parse(): Argument #1 ($uri) must not contain any null bytes

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - all components
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://user:info@example.com:443/foo/bar?abc=123&def=ghi#hashmark");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(4) "user"
["password"]=>
string(4) "info"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(8) "/foo/bar"
["query"]=>
string(15) "abc=123&def=ghi"
["fragment"]=>
string(8) "hashmark"
}
string(62) "https://user:info@example.com/foo/bar?abc=123&def=ghi#hashmark"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - mailto email
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("mailto:user@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(6) "mailto"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(16) "user@example.com"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(23) "mailto:user@example.com"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - file
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("file:///E:/Documents%20and%20Settings");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "file"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(0) ""
["port"]=>
NULL
["path"]=>
string(30) "/E:/Documents%20and%20Settings"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(37) "file:///E:/Documents%20and%20Settings"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - basic - URN
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(3) "urn"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(41) "uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(45) "urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - invalid code point
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://ex[a]mple.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (DomainInvalidCodePoint)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - empty
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (HostMissing)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - empty
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://user:pass@");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - empty
--FILE--
<?php
try {
new Uri\WhatWg\Url("/");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - IPvFuture
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://[v7.host]");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (Ipv6InvalidCodePoint)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - empty
--FILE--
<?php
try {
new Uri\WhatWg\Url("///");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - IPv4
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://192.168.0.1");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "192.168.0.1"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(20) "https://192.168.0.1/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - wrong IPv4 format
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://192.168");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "192.0.0.168"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(20) "https://192.0.0.168/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - IPv6
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://[2001:0db8:3333:4444:5555:6666:7777:8888]");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(49) "https://[2001:db8:3333:4444:5555:6666:7777:8888]/"

View File

@@ -0,0 +1,33 @@
--TEST--
Test Uri\WhatWg\Url parsing - host - multibyte codepoint
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://exḁmple.com");
var_dump($url);
var_dump($url->toAsciiString());
var_dump($url->toUnicodeString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(19) "xn--exmple-xf7b.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(28) "https://xn--exmple-xf7b.com/"
string(22) "https://exḁmple.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - password - empty
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://user:@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(4) "user"
["password"]=>
string(0) ""
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(25) "https://user@example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - password - extended ASCII character
--FILE--
<?php
$url = new Uri\WhatWg\Url("http://user:pásswörd@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
string(4) "user"
["password"]=>
string(18) "p%C3%A1ssw%C3%B6rd"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(43) "http://user:p%C3%A1ssw%C3%B6rd@example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - password - multibyte codepoint
--FILE--
<?php
$url = new Uri\WhatWg\Url("http://user:pąss@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
string(4) "user"
["password"]=>
string(9) "p%C4%85ss"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(34) "http://user:p%C4%85ss@example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - password - codepoint in percent-encode set
--FILE--
<?php
$url = new Uri\WhatWg\Url("http://user:pa|s@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
string(4) "user"
["password"]=>
string(6) "pa%7Cs"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(31) "http://user:pa%7Cs@example.com/"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - relative reference
--FILE--
<?php
try {
new Uri\WhatWg\Url("foo");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - relative reference
--FILE--
<?php
try {
new Uri\WhatWg\Url("/foo");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - relative reference
--FILE--
<?php
try {
new Uri\WhatWg\Url("?query#fragment");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - multibyte
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://example.com/fȎȎ");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(14) "/f%C8%8E%C8%8E"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(33) "https://example.com/f%C8%8E%C8%8E"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - codepoint in percent-encode set
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://example.com/foo\"/<bar>/^{baz}");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(28) "/foo%22/%3Cbar%3E/^%7Bbaz%7D"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(47) "https://example.com/foo%22/%3Cbar%3E/^%7Bbaz%7D"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - slash only
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://example.com/");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(20) "https://example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - path - special characters
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://example.com/fo[o/ba]r/baz=q@z,&");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(20) "/fo[o/ba]r/baz=q@z,&"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(39) "https://example.com/fo[o/ba]r/baz=q@z,&"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - port - multibyte
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://example.com:Ȏ");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - port - negative value
--FILE--
<?php
try {
new Uri\WhatWg\Url("http://example.com:-1");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - port - percent encoded character
--FILE--
<?php
try {
new Uri\WhatWg\Url("https://example.com:%30");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - port - user info component is in wrong place
--FILE--
<?php
try {
var_dump(new Uri\WhatWg\Url("https://example.com:8080@username:password"));
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid)

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - port - empty
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("http://example.com:");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(19) "http://example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - port - zero
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("http://example.com:0");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
int(0)
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(21) "http://example.com:0/"

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - empty
--FILE--
<?php
try {
new Uri\WhatWg\Url("://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - invalid character
--FILE--
<?php
try {
new Uri\WhatWg\Url("http&://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - multibyte codepoint
--FILE--
<?php
try {
new Uri\WhatWg\Url("ƕŢŢƤƨ://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - only scheme
--FILE--
<?php
try {
new Uri\WhatWg\Url("http:");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (HostMissing)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - only scheme
--FILE--
<?php
try {
new Uri\WhatWg\Url("http:/");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (HostMissing)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - percent encoded character
--FILE--
<?php
try {
new Uri\WhatWg\Url("http%2F://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,14 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - invalid character
--FILE--
<?php
try {
new Uri\WhatWg\Url("hÁttp://example.com");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - IANA scheme
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("chrome-extension://example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(16) "chrome-extension"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(0) ""
["query"]=>
NULL
["fragment"]=>
NULL
}
string(30) "chrome-extension://example.com"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - scheme - without //
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https:example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
NULL
["password"]=>
NULL
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(20) "https://example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - username - empty
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://:pass@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(0) ""
["password"]=>
string(4) "pass"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(26) "https://:pass@example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - username - extended ASCII character
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://úzör@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(14) "%C3%BAz%C3%B6r"
["password"]=>
string(0) ""
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(35) "https://%C3%BAz%C3%B6r@example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - username - multibyte codepoint
--FILE--
<?php
$url = new Uri\WhatWg\Url("https://usĕr:pass@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
string(9) "us%C4%95r"
["password"]=>
string(4) "pass"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(35) "https://us%C4%95r:pass@example.com/"

View File

@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - username - codepoint in percent-encode set
--FILE--
<?php
$url = new Uri\WhatWg\Url("http://us[er]:pass@example.com");
var_dump($url);
var_dump($url->toAsciiString());
?>
--EXPECTF--
object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(4) "http"
["username"]=>
string(10) "us%5Ber%5D"
["password"]=>
string(4) "pass"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(35) "http://us%5Ber%5D:pass@example.com/"