com php-src: Fixed parse_url() for better complianc e with RFC3986: ext/standard/tests/url/parse_ url_basic_001.phpt ext/standard/tests/url/parse
_url_basic_002.phpt ext/standard/tests/url/pars e_url_basic_003.phpt ext/standard/tests/url/par se_url_basic_004.phpt ext/standard/tests/url/pa
rse_url_basic_005.phpt ext/standard/tests/url/p arse_url_basic_006.phpt ext/standard/tests/url/ parse_url_basic_007.phpt ext/standard/tests/url
/parse_url_basic_008.phpt
| From: | JulienPauli | Date: | Wed, 22 Jun 2016 12:05:25 +0000 |
| Subject: | com php-src: Fixed parse_url() for better complianc e with RFC3986: ext/standard/tests/url/parse_ url_basic_001.phpt ext/standard/tests/url/parse _url_basic_002.phpt ext/standard/tests/url/pars e_url_basic_003.phpt ext/standard/tests/url/par se_url_basic_004.phpt ext/standard/tests/url/pa rse_url_basic_005.phpt ext/standard/tests/url/p arse_url_basic_006.phpt ext/standard/tests/url/ parse_url_basic_007.phpt ext/standard/tests/url /parse_url_basic_008.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92607@lists.php.net to get a copy of this message | ||
Commit: e2add3ed871886d1b2c7aeb4afb80ae1401e11b9
Author: Julien Pauli <jpauli@php.net> Tue, 21 Jun 2016 12:45:49 +0200
Parents: 9c1fba8593868251a3bfc7f6a8b8532c0570461d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e2add3ed871886d1b2c7aeb4afb80ae1401e11b9
Log:
Fixed parse_url() for better compliance with RFC3986
Changed paths:
M ext/standard/tests/url/parse_url_basic_001.phpt
M ext/standard/tests/url/parse_url_basic_002.phpt
M ext/standard/tests/url/parse_url_basic_003.phpt
M ext/standard/tests/url/parse_url_basic_004.phpt
M ext/standard/tests/url/parse_url_basic_005.phpt
M ext/standard/tests/url/parse_url_basic_006.phpt
M ext/standard/tests/url/parse_url_basic_007.phpt
M ext/standard/tests/url/parse_url_basic_008.phpt
M ext/standard/tests/url/parse_url_basic_009.phpt
M ext/standard/tests/url/urls.inc
M ext/standard/url.c
Diff:
diff --git a/ext/standard/tests/url/parse_url_basic_001.phpt
b/ext/standard/tests/url/parse_url_basic_001.phpt
index e482566..2d41ba9 100644
--- a/ext/standard/tests/url/parse_url_basic_001.phpt
+++ b/ext/standard/tests/url/parse_url_basic_001.phpt
@@ -608,6 +608,21 @@ echo "Done";
string(12) "bar=1&boom=0"
}
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0:
array(6) {
+ ["scheme"]=>
+ string(4) "http"
+ ["host"]=>
+ string(15) "www.example.com"
+ ["port"]=>
+ int(8080)
+ ["user"]=>
+ string(11) "user_me-you"
+ ["pass"]=>
+ string(11) "my_pas-word"
+ ["query"]=>
+ string(12) "bar=1&boom=0"
+}
+
--> file:///path/to/file: array(2) {
["scheme"]=>
string(4) "file"
diff --git a/ext/standard/tests/url/parse_url_basic_002.phpt
b/ext/standard/tests/url/parse_url_basic_002.phpt
index b68a82f..476b897 100644
--- a/ext/standard/tests/url/parse_url_basic_002.phpt
+++ b/ext/standard/tests/url/parse_url_basic_002.phpt
@@ -80,6 +80,7 @@ echo "Done";
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: string(4) "http"
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: string(4) "http"
--> file:///path/to/file : string(4) "file"
--> file://path/to/file : string(4) "file"
--> file:/path/to/file : string(4) "file"
diff --git a/ext/standard/tests/url/parse_url_basic_003.phpt
b/ext/standard/tests/url/parse_url_basic_003.phpt
index 19ee322..c7f3d99 100644
--- a/ext/standard/tests/url/parse_url_basic_003.phpt
+++ b/ext/standard/tests/url/parse_url_basic_003.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: string(15) "www.example.com"
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: string(15) "www.example.com"
--> file:///path/to/file : NULL
--> file://path/to/file : string(4) "path"
--> file:/path/to/file : NULL
diff --git a/ext/standard/tests/url/parse_url_basic_004.phpt
b/ext/standard/tests/url/parse_url_basic_004.phpt
index e26b397..3cfb345 100644
--- a/ext/standard/tests/url/parse_url_basic_004.phpt
+++ b/ext/standard/tests/url/parse_url_basic_004.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: int(8080)
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: int(8080)
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
diff --git a/ext/standard/tests/url/parse_url_basic_005.phpt
b/ext/standard/tests/url/parse_url_basic_005.phpt
index df2095a..602bd60 100644
--- a/ext/standard/tests/url/parse_url_basic_005.phpt
+++ b/ext/standard/tests/url/parse_url_basic_005.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: string(4) "user"
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: string(11) "user_me-you"
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
diff --git a/ext/standard/tests/url/parse_url_basic_006.phpt
b/ext/standard/tests/url/parse_url_basic_006.phpt
index 4c79e8d..69b7914 100644
--- a/ext/standard/tests/url/parse_url_basic_006.phpt
+++ b/ext/standard/tests/url/parse_url_basic_006.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : NULL
--> foo..php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: string(6) "passwd"
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: string(11) "my_pas-word"
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
diff --git a/ext/standard/tests/url/parse_url_basic_007.phpt
b/ext/standard/tests/url/parse_url_basic_007.phpt
index 52f3a92..a8cbf2f 100644
--- a/ext/standard/tests/url/parse_url_basic_007.phpt
+++ b/ext/standard/tests/url/parse_url_basic_007.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : string(8) "/foo.php"
--> foo.php?a=b&c=d : string(7) "foo.php"
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: NULL
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: NULL
--> file:///path/to/file : string(13) "/path/to/file"
--> file://path/to/file : string(8) "/to/file"
--> file:/path/to/file : string(13) "/path/to/file"
diff --git a/ext/standard/tests/url/parse_url_basic_008.phpt
b/ext/standard/tests/url/parse_url_basic_008.phpt
index 874c901..21ead3b 100644
--- a/ext/standard/tests/url/parse_url_basic_008.phpt
+++ b/ext/standard/tests/url/parse_url_basic_008.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : string(7) "a=b&c=d"
--> foo.php?a=b&c=d : string(7) "a=b&c=d"
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: string(12) "bar=1&boom=0"
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: string(12) "bar=1&boom=0"
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
diff --git a/ext/standard/tests/url/parse_url_basic_009.phpt
b/ext/standard/tests/url/parse_url_basic_009.phpt
index ea0b257..29e8312 100644
--- a/ext/standard/tests/url/parse_url_basic_009.phpt
+++ b/ext/standard/tests/url/parse_url_basic_009.phpt
@@ -79,6 +79,7 @@ echo "Done";
--> /foo.php?a=b&c=d : NULL
--> foo.php?a=b&c=d : NULL
--> http://user:passwd@www.example.com:8080?bar=1&boom=0
: NULL
+--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0
: NULL
--> file:///path/to/file : NULL
--> file://path/to/file : NULL
--> file:/path/to/file : NULL
diff --git a/ext/standard/tests/url/urls.inc b/ext/standard/tests/url/urls.inc
index 6228bd8..c994244 100644
--- a/ext/standard/tests/url/urls.inc
+++ b/ext/standard/tests/url/urls.inc
@@ -59,6 +59,7 @@ $urls = array(
'/foo.php?a=b&c=d',
'foo.php?a=b&c=d',
'http://user:passwd@www.example.com:8080?bar=1&boom=0',
+'http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0',
'file:///path/to/file',
'file://path/to/file',
'file:/path/to/file',
diff --git a/ext/standard/url.c b/ext/standard/url.c
index d69c11f..a33ff9a 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -245,7 +245,9 @@ PHPAPI php_url *php_url_parse_ex(char const *str, size_t length)
/* check for invalid chars inside login/pass */
pp = s;
while (pp < p) {
- if (!isalnum(*pp) && *pp != ':' && *pp != ';' && *pp
!= '=' && !(*pp >= '!' && *pp <= ',')) {
+ /* http://www.rfc-editor.org/rfc/rfc3986.txt
§3.2.1 */
+ const char search_rfc3986[] = ":;=!$%_-.~&'()*+,";
+ if (!isalnum(*pp) && !strchr(search_rfc3986, *pp)) {
if (ret->scheme) {
efree(ret->scheme);
}