Skip to content

Commit

Permalink
Bug 1087380 - avoid alternate (www....com) URI fixup for localhost an…
Browse files Browse the repository at this point in the history
…d items with ports, r=bz

MozReview-Commit-ID: HB9SxRSWnz

--HG--
extra : rebase_source : 99a9708588b277e31c8082b9579371609fc658d1
  • Loading branch information
gijsk committed May 6, 2017
1 parent b8329c3 commit faf81a4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
13 changes: 12 additions & 1 deletion docshell/base/nsDefaultURIFixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,22 @@ nsDefaultURIFixup::MakeAlternateURI(nsIURI* aURI)
if (!userpass.IsEmpty()) {
return false;
}
// Don't fix up hosts with ports
int32_t port;
aURI->GetPort(&port);
if (port != -1) {
return false;
}

nsAutoCString oldHost;
nsAutoCString newHost;
aURI->GetHost(oldHost);

// Don't fix up 'localhost' because that's confusing:
if (oldHost.EqualsLiteral("localhost")) {
return false;
}

nsAutoCString newHost;
// Count the dots
int32_t numDots = 0;
nsReadingIterator<char> iter;
Expand Down
20 changes: 16 additions & 4 deletions docshell/test/unit/test_nsDefaultURIFixup_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,10 @@ var testcases = [ {
}, {
input: "[::1]:8000",
fixedURI: "http://[::1]:8000/",
alternateURI: "http://[::1]:8000/",
protocolChange: true,
}, {
input: "[::1]:8000/",
fixedURI: "http://[::1]:8000/",
alternateURI: "http://[::1]:8000/",
protocolChange: true,
}, {
input: "[[::1]]/",
Expand Down Expand Up @@ -215,7 +213,6 @@ var testcases = [ {
}, {
input: "[::1][100",
fixedURI: null,
alternateURI: null,
keywordLookup: true,
protocolChange: true
}, {
Expand Down Expand Up @@ -471,7 +468,22 @@ var testcases = [ {
keywordLookup: true,
protocolChange: true,
affectedByDNSForSingleHosts: true,
}];
}, {
input: "localhost",
fixedURI: "http://localhost/",
keywordLookup: true,
protocolChange: true,
affectedByDNSForSingleHosts: true,
}, {
input: "localhost:8080",
fixedURI: "http://localhost:8080/",
protocolChange: true,
}, {
input: "plonk:8080",
fixedURI: "http://plonk:8080/",
protocolChange: true,
}
];

if (Services.appinfo.OS.toLowerCase().startsWith("win")) {
testcases.push({
Expand Down

0 comments on commit faf81a4

Please sign in to comment.