Bug 1558408 - fix fixup of host port URLs with querystrings or refs without forward slashes, r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D52847

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-11-13 18:07:40 +00:00
parent 35cf6bc398
commit e618913512
2 changed files with 14 additions and 2 deletions

View File

@ -748,13 +748,13 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString& aUrl) {
++iter;
// Count the number of digits after the colon and before the
// next forward slash (or end of string)
// next forward slash, question mark, hash sign, or end of string.
uint32_t digitCount = 0;
while (iter != iterEnd && digitCount <= 5) {
if (IsAsciiDigit(*iter)) {
digitCount++;
} else if (*iter == '/') {
} else if (*iter == '/' || *iter == '?' || *iter == '#') {
break;
} else {
// Whatever it is, it ain't a port!

View File

@ -83,6 +83,18 @@ var data = [
wrong: "://user:pass@example.com:8080/this/is/a/test.html",
fixed: "http://user:pass@example.com:8080/this/is/a/test.html",
},
{
wrong: "localhost:8080/?param=1",
fixed: "http://localhost:8080/?param=1",
},
{
wrong: "localhost:8080?param=1",
fixed: "http://localhost:8080/?param=1",
},
{
wrong: "localhost:8080#somewhere",
fixed: "http://localhost:8080/#somewhere",
},
{
wrong: "whatever://this/is/a@b/test.html",
fixed: kSearchEngineURL.replace(