Skip to content

Commit

Permalink
Add default port for the gopher: scheme.
Browse files Browse the repository at this point in the history
KURL parsing uses known_ports.cc for supporting known ports for standard
schemes. GURL uses its own version, which leads to mismatch in behavior.

This CL adds gopher's default port to known_ports.cc, however a follow
up patch should just remove gopher support in general.

Bug: 894426
Change-Id: I9cde04bef34be39337cdb9f2a584de576d0b15ea
Reviewed-on: https://chromium-review.googlesource.com/c/1279408
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599812}
  • Loading branch information
naskooskov authored and Commit Bot committed Oct 16, 2018
1 parent 012876a commit 116094f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions third_party/blink/renderer/platform/weborigin/known_ports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ bool IsDefaultPortForProtocol(unsigned short port,
return protocol == "ftp";
case 990:
return protocol == "ftps";
case 70:
return protocol == "gopher";
}
return false;
}
Expand All @@ -60,6 +62,8 @@ unsigned short DefaultPortForProtocol(const WTF::String& protocol) {
return 21;
if (protocol == "ftps")
return 990;
if (protocol == "gopher")
return 70;

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ TEST_F(SecurityOriginTest, CreateFromTuple) {
{"https", "example.com", 444, "https://example.com:444"},
{"file", "", 0, "file://"},
{"file", "example.com", 0, "file://"},
{"gopher", "Foo.com", 70, "gopher://foo.com"},
};

for (const auto& test : cases) {
Expand Down Expand Up @@ -536,6 +537,9 @@ TEST_F(SecurityOriginTest, UrlOriginConversions) {
123},
{"blob:https://example.com/guid-goes-here", "https", "example.com", 443},
{"blob:http://u:p@example.com/guid-goes-here", "http", "example.com", 80},

// Gopher:
{"gopher://8u.9.Vx6/", "gopher", "8u.9.vx6", 70},
};

for (const auto& test_case : cases) {
Expand Down
3 changes: 3 additions & 0 deletions url/origin_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ TEST_F(OriginTest, ConstructFromGURL) {
123},
{"blob:https://example.com/guid-goes-here", "https", "example.com", 443},
{"blob:http://u:p@example.com/guid-goes-here", "http", "example.com", 80},

// Gopher:
{"gopher://8u.9.Vx6", "gopher", "8u.9.vx6", 70},
};

for (const auto& test_case : cases) {
Expand Down

0 comments on commit 116094f

Please sign in to comment.