-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #77423: parse_url() will deliver a wrong host to user
To avoid that `parse_url()` returns an erroneous host, which would be valid for `FILTER_VALIDATE_URL`, we make sure that only userinfo which is valid according to RFC 3986 is treated as such. For consistency with the existing url parsing code, we use ctype functions, although that is not necessarily correct.
- Loading branch information
Showing
7 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--TEST-- | ||
Bug #77423 (parse_url() will deliver a wrong host to user) | ||
--FILE-- | ||
<?php | ||
$urls = array( | ||
"http://php.net\@aliyun.com/aaa.do", | ||
"https://example.com\uFF03@bing.com", | ||
); | ||
foreach ($urls as $url) { | ||
var_dump(filter_var($url, FILTER_VALIDATE_URL)); | ||
var_dump(parse_url($url)); | ||
} | ||
?> | ||
--EXPECT-- | ||
bool(false) | ||
array(3) { | ||
["scheme"]=> | ||
string(4) "http" | ||
["host"]=> | ||
string(19) "php.net\@aliyun.com" | ||
["path"]=> | ||
string(7) "/aaa.do" | ||
} | ||
bool(false) | ||
array(2) { | ||
["scheme"]=> | ||
string(5) "https" | ||
["host"]=> | ||
string(26) "example.com\uFF03@bing.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters