Skip to content
Closed
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
12 changes: 4 additions & 8 deletions ext/standard/tests/url/parse_url_basic_011.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ var_dump(parse_url('magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C'));
--EXPECT--
*** Testing parse_url() :can not recognize port without scheme ***
parse 127.0.0.1:9999?
array(3) {
["scheme"]=>
string(9) "127.0.0.1"
array(2) {
["path"]=>
string(4) "9999"
string(14) "127.0.0.1:9999"
["query"]=>
string(0) ""
}
parse 127.0.0.1:9999#
array(3) {
["scheme"]=>
string(9) "127.0.0.1"
array(2) {
["path"]=>
string(4) "9999"
string(14) "127.0.0.1:9999"
["fragment"]=>
string(0) ""
}
Expand Down
27 changes: 27 additions & 0 deletions ext/standard/tests/url/parse_url_rfc3986_scheme.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Test parse_url() function: Checks URL schemes should start with alpha characters.
--FILE--
<?php
$urls = [
'valid-scheme://example.org',
'0invalid-scheme://example.org',
'-invalid-scheme://example.org',
'+invalid-scheme://example.org',
'.invalid-scheme://example.org'
];
foreach ($urls as $url) {
echo "parse {$url}\n";
var_dump(parse_url($url, PHP_URL_SCHEME));
}
?>
--EXPECT--
parse valid-scheme://example.org
string(12) "valid-scheme"
parse 0invalid-scheme://example.org
NULL
parse -invalid-scheme://example.org
NULL
parse +invalid-scheme://example.org
NULL
parse .invalid-scheme://example.org
NULL
4 changes: 2 additions & 2 deletions ext/standard/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
/* validate scheme */
p = s;
while (p < e) {
/* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ] */
if (!isalpha(*p) && !isdigit(*p) && *p != '+' && *p != '.' && *p != '-') {
/* scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) */
if (!isalpha(*p) && (p == s || (!isdigit(*p) && *p != '+' && *p != '.' && *p != '-'))) {
if (e + 1 < ue && e < binary_strcspn(s, ue, "?#")) {
goto parse_port;
} else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
Expand Down
Loading