Bug 1661423 - dont apply upgrade-insecure-requests to localhost form submissions r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D88577
This commit is contained in:
Frederik Braun
2020-08-31 10:11:37 +00:00
parent c91e914e12
commit a251196a3b
4 changed files with 61 additions and 13 deletions

View File

@@ -1693,9 +1693,13 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
// Potentially the page uses the CSP directive 'upgrade-insecure-requests'. In
// such a case we have to upgrade the action url from http:// to https://.
// If the actionURL is not http, then there is nothing to do.
bool isHttpScheme = actionURL->SchemeIs("http");
if (isHttpScheme && document->GetUpgradeInsecureRequests(false)) {
// The upgrade is only required if the actionURL is http and not a potentially
// trustworthy loopback URI.
bool needsUpgrade =
actionURL->SchemeIs("http") &&
!nsMixedContentBlocker::IsPotentiallyTrustworthyLoopbackURL(actionURL) &&
document->GetUpgradeInsecureRequests(false);
if (needsUpgrade) {
// let's use the old specification before the upgrade for logging
AutoTArray<nsString, 2> params;
nsAutoCString spec;