summaryrefslogtreecommitdiffstats
path: root/docshell/base/nsDocShell.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-02-22 11:47:32 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-02-22 11:47:32 +0100
commit7b7ea5c59a6f282be1d02a199f46483447ec00c1 (patch)
tree8687a74d52001a48b616a8fc30e3ada54d19cb0c /docshell/base/nsDocShell.cpp
parentb7274fd666e1bb33effc1425701f566bcaa6f7be (diff)
parentcff4a7d0b65b9cfe272d72f7a26e3dcc33ea0a03 (diff)
downloadUXP-7b7ea5c59a6f282be1d02a199f46483447ec00c1.tar
UXP-7b7ea5c59a6f282be1d02a199f46483447ec00c1.tar.gz
UXP-7b7ea5c59a6f282be1d02a199f46483447ec00c1.tar.lz
UXP-7b7ea5c59a6f282be1d02a199f46483447ec00c1.tar.xz
UXP-7b7ea5c59a6f282be1d02a199f46483447ec00c1.zip
Merge branch 'ported-moebius'
Diffstat (limited to 'docshell/base/nsDocShell.cpp')
-rw-r--r--docshell/base/nsDocShell.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index ab119a016..2e08e6720 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -11025,6 +11025,29 @@ nsDocShell::DoURILoad(nsIURI* aURI,
}
}
+ // Navigational requests that are same origin need to be upgraded in case
+ // upgrade-insecure-requests is present. Please note that in that case
+ // the triggeringPrincipal is holding the CSP that potentially
+ // holds upgrade-insecure-requests.
+ nsCOMPtr<nsIContentSecurityPolicy> csp;
+ aTriggeringPrincipal->GetCsp(getter_AddRefs(csp));
+ if (csp) {
+ bool upgradeInsecureRequests = false;
+ csp->GetUpgradeInsecureRequests(&upgradeInsecureRequests);
+ if (upgradeInsecureRequests) {
+ // only upgrade if the navigation is same origin
+ nsCOMPtr<nsIPrincipal> resultPrincipal;
+ rv = nsContentUtils::GetSecurityManager()->
+ GetChannelResultPrincipal(channel,
+ getter_AddRefs(resultPrincipal));
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (resultPrincipal->Equals(aTriggeringPrincipal)) {
+ static_cast<mozilla::LoadInfo*>(loadInfo.get())->SetUpgradeInsecureRequests();
+ }
+ }
+ }
+
+
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
do_QueryInterface(channel);
if (appCacheChannel) {