Bug 1792635 - Prevent DNS not found page from suggesting the same URI - r=mak

I modified the boolean associated with fixupCreateAlternateURI to only
be true if the host which contains the prefix and suffix differs from
the fixed up version. This will allow the boolean to be false in cases
where the fixup doesn't change the host. Then for the DNS error page,
there is a check as to whether the host or protocol was changed.

Differential Revision: https://phabricator.services.mozilla.com/D159175
This commit is contained in:
James Teow 2022-10-18 13:24:51 +00:00
parent be7ce82637
commit b1eefaa0d6
3 changed files with 9 additions and 2 deletions

View File

@ -1284,6 +1284,7 @@ function maybeAddPrefixAndSuffix(oldHost) {
* @throws If a non-NS_ERROR_MALFORMED_URI error occurs. * @throws If a non-NS_ERROR_MALFORMED_URI error occurs.
*/ */
function updateHostAndScheme(info, newHost) { function updateHostAndScheme(info, newHost) {
let oldHost = info.fixedURI.host;
let oldScheme = info.fixedURI.scheme; let oldScheme = info.fixedURI.scheme;
try { try {
info.fixedURI = info.fixedURI info.fixedURI = info.fixedURI
@ -1300,6 +1301,8 @@ function updateHostAndScheme(info, newHost) {
if (oldScheme != info.fixedURI.scheme) { if (oldScheme != info.fixedURI.scheme) {
info.fixupChangedProtocol = true; info.fixupChangedProtocol = true;
} }
info.fixupCreatedAlternateURI = true; if (oldHost != info.fixedURI.host) {
info.fixupCreatedAlternateURI = true;
}
return true; return true;
} }

View File

@ -14,22 +14,26 @@ var data = [
// upgrade protocol. // upgrade protocol.
wrong: "http://www.example.com/", wrong: "http://www.example.com/",
fixed: "https://www.example.com/", fixed: "https://www.example.com/",
noAlternateURI: true,
}, },
{ {
// no difference. // no difference.
wrong: "https://www.example.com/", wrong: "https://www.example.com/",
fixed: "https://www.example.com/", fixed: "https://www.example.com/",
noProtocolFixup: true, noProtocolFixup: true,
noAlternateURI: true,
}, },
{ {
// don't add prefix when there's more than one dot. // don't add prefix when there's more than one dot.
wrong: "http://www.example.abc.def/", wrong: "http://www.example.abc.def/",
fixed: "https://www.example.abc.def/", fixed: "https://www.example.abc.def/",
noAlternateURI: true,
}, },
{ {
// http -> https. // http -> https.
wrong: "http://www.example/", wrong: "http://www.example/",
fixed: "https://www.example/", fixed: "https://www.example/",
noAlternateURI: true,
}, },
{ {
// domain.com -> https://www.domain.com. // domain.com -> https://www.domain.com.

View File

@ -89,7 +89,7 @@ class NetErrorChild extends RemotePageChild {
this.contentWindow.location.href this.contentWindow.location.href
); );
if (!info.fixupCreatedAlternateURI) { if (!info.fixupCreatedAlternateURI && !info.fixupChangedProtocol) {
return; return;
} }