forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GURL] (2 of 2) Strip username/password/port when canonicalizing, if …
…the scheme doesn't support them The goal of this CL is to inhibit port numbers and usernames in internal schemes like "chrome-extension" and "chrome". Currently, navigations to chrome-extension:// URLs with ports actually get suprisingly far; it seems like no good can possibly come from that. A new SchemeType is added: SCHEME_WITH_HOST_AND_PORT (no user information). This is only used when canonicalizing the inner URL of filesystem: -- e.g., filesystem:http://user@host:20/temp/foo now canonicalizes to filesystem:http://host:20/temp/foo; whereas filesystem:chrome://user@host:20/temp/foo canonicalizes to filesystem:chrome://host/temp/foo Bug: 606001,809062 Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs Change-Id: I77c5ba3d2fe964deb8aadae95a06519ce038c472 Reviewed-on: https://chromium-review.googlesource.com/974380 Reviewed-by: Vasilii Sukhanov <[email protected]> Reviewed-by: Tommy Li <[email protected]> Reviewed-by: Mike West <[email protected]> Commit-Queue: Nick Carter <[email protected]> Cr-Commit-Position: refs/heads/master@{#547882}
- Loading branch information
1 parent
3e0db46
commit ff69a10
Showing
12 changed files
with
237 additions
and
158 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 |
---|---|---|
|
@@ -248,64 +248,64 @@ struct FixupCase { | |
const std::string input; | ||
const std::string output; | ||
} fixup_cases[] = { | ||
{"www.google.com", "http://www.google.com/"}, | ||
{" www.google.com ", "http://www.google.com/"}, | ||
{" foo.com/asdf bar", "http://foo.com/asdf%20%20bar"}, | ||
{"..www.google.com..", "http://www.google.com./"}, | ||
{"http://......", "http://....../"}, | ||
{"http://host.com:ninety-two/", "http://host.com:ninety-two/"}, | ||
{"http://host.com:ninety-two?foo", "http://host.com:ninety-two/?foo"}, | ||
{"google.com:123", "http://google.com:123/"}, | ||
{"about:", "chrome://version/"}, | ||
{"about:foo", "chrome://foo/"}, | ||
{"about:version", "chrome://version/"}, | ||
{"about:blank", "about:blank"}, | ||
{"about:usr:pwd@hst/pth?qry#ref", "chrome://usr:pwd@hst/pth?qry#ref"}, | ||
{"about://usr:pwd@hst/pth?qry#ref", "chrome://usr:pwd@hst/pth?qry#ref"}, | ||
{"chrome:usr:pwd@hst/pth?qry#ref", "chrome://usr:pwd@hst/pth?qry#ref"}, | ||
{"chrome://usr:pwd@hst/pth?qry#ref", "chrome://usr:pwd@hst/pth?qry#ref"}, | ||
{"www:123", "http://www:123/"}, | ||
{" www:123", "http://www:123/"}, | ||
{"www.google.com?foo", "http://www.google.com/?foo"}, | ||
{"www.google.com#foo", "http://www.google.com/#foo"}, | ||
{"www.google.com?", "http://www.google.com/?"}, | ||
{"www.google.com#", "http://www.google.com/#"}, | ||
{"www.google.com:123?foo#bar", "http://www.google.com:123/?foo#bar"}, | ||
{"[email protected]", "http://[email protected]/"}, | ||
{"\xE6\xB0\xB4.com", "http://xn--1rw.com/"}, | ||
// It would be better if this next case got treated as http, but I don't see | ||
// a clean way to guess this isn't the new-and-exciting "user" scheme. | ||
{"user:[email protected]:8080/", "user:[email protected]:8080/"}, | ||
// {"file:///c:/foo/bar%20baz.txt", "file:///C:/foo/bar%20baz.txt"}, | ||
// URLs which end with 0x85 (NEL in ISO-8859). | ||
{"http://foo.com/s?q=\xd0\x85", "http://foo.com/s?q=%D0%85"}, | ||
{"http://foo.com/s?q=\xec\x97\x85", "http://foo.com/s?q=%EC%97%85"}, | ||
{"http://foo.com/s?q=\xf0\x90\x80\x85", "http://foo.com/s?q=%F0%90%80%85"}, | ||
// URLs which end with 0xA0 (non-break space in ISO-8859). | ||
{"http://foo.com/s?q=\xd0\xa0", "http://foo.com/s?q=%D0%A0"}, | ||
{"http://foo.com/s?q=\xec\x97\xa0", "http://foo.com/s?q=%EC%97%A0"}, | ||
{"http://foo.com/s?q=\xf0\x90\x80\xa0", "http://foo.com/s?q=%F0%90%80%A0"}, | ||
// URLs containing IPv6 literals. | ||
{"[2001:db8::2]", "http://[2001:db8::2]/"}, | ||
{"[::]:80", "http://[::]/"}, | ||
{"[::]:80/path", "http://[::]/path"}, | ||
{"[::]:180/path", "http://[::]:180/path"}, | ||
// TODO(pmarks): Maybe we should parse bare IPv6 literals someday. Currently | ||
// the first colon is treated as a scheme separator, and we default | ||
// unspecified schemes to "http". | ||
{"::1", "http://:1/"}, | ||
// Semicolon as scheme separator for standard schemes. | ||
{"http;//www.google.com/", "http://www.google.com/"}, | ||
{"about;chrome", "chrome://chrome/"}, | ||
// Semicolon in non-standard schemes is not replaced by colon. | ||
{"whatsup;//fool", "http://whatsup%3B//fool"}, | ||
// Semicolon left as-is in URL itself. | ||
{"http://host/port?query;moar", "http://host/port?query;moar"}, | ||
// Fewer slashes than expected. | ||
{"http;www.google.com/", "http://www.google.com/"}, | ||
{"http;/www.google.com/", "http://www.google.com/"}, | ||
// Semicolon at start. | ||
{";http://www.google.com/", "http://%3Bhttp//www.google.com/"}, | ||
{"www.google.com", "http://www.google.com/"}, | ||
{" www.google.com ", "http://www.google.com/"}, | ||
{" foo.com/asdf bar", "http://foo.com/asdf%20%20bar"}, | ||
{"..www.google.com..", "http://www.google.com./"}, | ||
{"http://......", "http://....../"}, | ||
{"http://host.com:ninety-two/", "http://host.com:ninety-two/"}, | ||
{"http://host.com:ninety-two?foo", "http://host.com:ninety-two/?foo"}, | ||
{"google.com:123", "http://google.com:123/"}, | ||
{"about:", "chrome://version/"}, | ||
{"about:foo", "chrome://foo/"}, | ||
{"about:version", "chrome://version/"}, | ||
{"about:blank", "about:blank"}, | ||
{"about:usr:pwd@hst:20/pth?qry#ref", "chrome://hst/pth?qry#ref"}, | ||
{"about://usr:pwd@hst/pth?qry#ref", "chrome://hst/pth?qry#ref"}, | ||
{"chrome:usr:pwd@hst/pth?qry#ref", "chrome://hst/pth?qry#ref"}, | ||
{"chrome://usr:pwd@hst/pth?qry#ref", "chrome://hst/pth?qry#ref"}, | ||
{"www:123", "http://www:123/"}, | ||
{" www:123", "http://www:123/"}, | ||
{"www.google.com?foo", "http://www.google.com/?foo"}, | ||
{"www.google.com#foo", "http://www.google.com/#foo"}, | ||
{"www.google.com?", "http://www.google.com/?"}, | ||
{"www.google.com#", "http://www.google.com/#"}, | ||
{"www.google.com:123?foo#bar", "http://www.google.com:123/?foo#bar"}, | ||
{"[email protected]", "http://[email protected]/"}, | ||
{"\xE6\xB0\xB4.com", "http://xn--1rw.com/"}, | ||
// It would be better if this next case got treated as http, but I don't see | ||
// a clean way to guess this isn't the new-and-exciting "user" scheme. | ||
{"user:[email protected]:8080/", "user:[email protected]:8080/"}, | ||
// {"file:///c:/foo/bar%20baz.txt", "file:///C:/foo/bar%20baz.txt"}, | ||
// URLs which end with 0x85 (NEL in ISO-8859). | ||
{"http://foo.com/s?q=\xd0\x85", "http://foo.com/s?q=%D0%85"}, | ||
{"http://foo.com/s?q=\xec\x97\x85", "http://foo.com/s?q=%EC%97%85"}, | ||
{"http://foo.com/s?q=\xf0\x90\x80\x85", "http://foo.com/s?q=%F0%90%80%85"}, | ||
// URLs which end with 0xA0 (non-break space in ISO-8859). | ||
{"http://foo.com/s?q=\xd0\xa0", "http://foo.com/s?q=%D0%A0"}, | ||
{"http://foo.com/s?q=\xec\x97\xa0", "http://foo.com/s?q=%EC%97%A0"}, | ||
{"http://foo.com/s?q=\xf0\x90\x80\xa0", "http://foo.com/s?q=%F0%90%80%A0"}, | ||
// URLs containing IPv6 literals. | ||
{"[2001:db8::2]", "http://[2001:db8::2]/"}, | ||
{"[::]:80", "http://[::]/"}, | ||
{"[::]:80/path", "http://[::]/path"}, | ||
{"[::]:180/path", "http://[::]:180/path"}, | ||
// TODO(pmarks): Maybe we should parse bare IPv6 literals someday. Currently | ||
// the first colon is treated as a scheme separator, and we default | ||
// unspecified schemes to "http". | ||
{"::1", "http://:1/"}, | ||
// Semicolon as scheme separator for standard schemes. | ||
{"http;//www.google.com/", "http://www.google.com/"}, | ||
{"about;chrome", "chrome://chrome/"}, | ||
// Semicolon in non-standard schemes is not replaced by colon. | ||
{"whatsup;//fool", "http://whatsup%3B//fool"}, | ||
// Semicolon left as-is in URL itself. | ||
{"http://host/port?query;moar", "http://host/port?query;moar"}, | ||
// Fewer slashes than expected. | ||
{"http;www.google.com/", "http://www.google.com/"}, | ||
{"http;/www.google.com/", "http://www.google.com/"}, | ||
// Semicolon at start. | ||
{";http://www.google.com/", "http://%3Bhttp//www.google.com/"}, | ||
}; | ||
|
||
TEST(URLFixerTest, FixupURL) { | ||
|
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
Oops, something went wrong.