Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static void create_rfc3986_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor
zend_object *base_url_object = NULL;

ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_PATH_STR(uri_str)
Z_PARAM_STR(uri_str)
Z_PARAM_OPTIONAL
Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, php_uri_ce_rfc3986_uri)
ZEND_PARSE_PARAMETERS_END();
Expand Down Expand Up @@ -490,7 +490,7 @@ static void create_whatwg_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor)
zval *errors = NULL;

ZEND_PARSE_PARAMETERS_START(1, 3)
Z_PARAM_PATH_STR(uri_str)
Z_PARAM_STR(uri_str)
Z_PARAM_OPTIONAL
Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, php_uri_ce_whatwg_url)
Z_PARAM_ZVAL(errors)
Expand Down Expand Up @@ -553,7 +553,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
zend_string *value;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_PATH_STR_OR_NULL(value)
Z_PARAM_STR_OR_NULL(value)
ZEND_PARSE_PARAMETERS_END();

zval zv;
Expand Down Expand Up @@ -769,7 +769,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, resolve)
zend_string *uri_str;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_PATH_STR(uri_str)
Z_PARAM_STR(uri_str)
ZEND_PARSE_PARAMETERS_END();

php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU,
Expand Down Expand Up @@ -956,7 +956,7 @@ PHP_METHOD(Uri_WhatWg_Url, resolve)
zval *errors = NULL;

ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_PATH_STR(uri_str)
Z_PARAM_STR(uri_str)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL(errors)
ZEND_PARSE_PARAMETERS_END();
Expand Down
4 changes: 2 additions & 2 deletions ext/uri/php_uri_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_pro
zend_string *value;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_PATH_STR(value)
Z_PARAM_STR(value)
ZEND_PARSE_PARAMETERS_END();

zval zv;
Expand All @@ -110,7 +110,7 @@ void php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php
zend_string *value;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_PATH_STR_OR_NULL(value)
Z_PARAM_STR_OR_NULL(value)
ZEND_PARSE_PARAMETERS_END();

zval zv;
Expand Down
39 changes: 0 additions & 39 deletions ext/uri/tests/035.phpt

This file was deleted.

18 changes: 18 additions & 0 deletions ext/uri/tests/rfc3986/modification/path_error_null_byte.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$uri = Uri\Rfc3986\Uri::parse("https://example.com");

try {
$uri->withPath("/\0foo");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Uri\InvalidUriException: The specified path is malformed
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Test Uri\Rfc3986\Uri parsing - basic - URI contains null byte

try {
new Uri\Rfc3986\Uri("https://exam\0ple.com");
} catch (ValueError $e) {
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
ValueError: Uri\Rfc3986\Uri::__construct(): Argument #1 ($uri) must not contain any null bytes
Uri\InvalidUriException: The specified URI is malformed
14 changes: 0 additions & 14 deletions ext/uri/tests/rfc3986/parsing/basic_error_null_byte2.phpt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri reference resolution - resolve() - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$uri = Uri\Rfc3986\Uri::parse("https://example.com");

try {
$uri->resolve("/f\0o");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Uri\InvalidUriException: The specified URI is malformed
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withFragment("frag\0ment");

var_dump($url1->getFragment());
var_dump($url2->getFragment());
var_dump($url2->toAsciiString());

?>
--EXPECT--
NULL
string(11) "frag%00ment"
string(32) "https://example.com/#frag%00ment"
18 changes: 18 additions & 0 deletions ext/uri/tests/whatwg/modification/host_error_null_byte.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url = Uri\WhatWg\Url::parse("https://example.com");

try {
$url->withHost("h\0st");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified host is malformed (DomainInvalidCodePoint)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withPassword("pass\0word");

var_dump($url1->getPassword());
var_dump($url2->getPassword());
var_dump($url2->toAsciiString());


?>
--EXPECT--
NULL
string(11) "pass%00word"
string(33) "https://:pass%00word@example.com/"
19 changes: 19 additions & 0 deletions ext/uri/tests/whatwg/modification/path_success_null_byte.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withPath("/p\0th\0");

var_dump($url1->getPath());
var_dump($url2->getPath());
var_dump($url2->toAsciiString());

?>
--EXPECT--
string(1) "/"
string(10) "/p%00th%00"
string(29) "https://example.com/p%00th%00"
19 changes: 19 additions & 0 deletions ext/uri/tests/whatwg/modification/query_success_null_byte.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - query - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withQuery("f\0o=bar&baz=q\0x");

var_dump($url1->getQuery());
var_dump($url2->getQuery());
var_dump($url2->toAsciiString());

?>
--EXPECT--
NULL
string(19) "f%00o=bar&baz=q%00x"
string(40) "https://example.com/?f%00o=bar&baz=q%00x"
18 changes: 18 additions & 0 deletions ext/uri/tests/whatwg/modification/scheme_error_null_byte.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - scheme - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url = Uri\WhatWg\Url::parse("https://example.com");

try {
$url->withScheme("sch\0me");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Test Uri\WhatWg\Url component modification - username - null byte
--EXTENSIONS--
uri
--FILE--
<?php

$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withUsername("usern\0me");

var_dump($url1->getUsername());
var_dump($url2->getUsername());
var_dump($url2->toAsciiString());


?>
--EXPECT--
NULL
string(10) "usern%00me"
string(31) "https://usern%00me@example.com/"
14 changes: 0 additions & 14 deletions ext/uri/tests/whatwg/parsing/basic_error_null_byte2.phpt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Test Uri\WhatWg\Url parsing - basic - URL contains null byte

try {
new Uri\WhatWg\Url("https://exam\0ple.com");
} catch (ValueError $e) {
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
ValueError: Uri\WhatWg\Url::__construct(): Argument #1 ($uri) must not contain any null bytes
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (DomainInvalidCodePoint)
31 changes: 31 additions & 0 deletions ext/uri/tests/whatwg/parsing/password_success_null_byte.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
Test Uri\WhatWg\Url parsing - password - null byte
--FILE--
<?php

$url = new Uri\WhatWg\Url("https://username:\0pass@example.com/");

var_dump($url);
var_dump($url->toAsciiString());

?>
--EXPECT--
object(Uri\WhatWg\Url)#1 (8) {
["scheme"]=>
string(5) "https"
["username"]=>
string(8) "username"
["password"]=>
string(7) "%00pass"
["host"]=>
string(11) "example.com"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
string(37) "https://username:%00pass@example.com/"
Loading