Bug 1804684 - Fragment navigation may change document URI scheme from https to http r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D165282
This commit is contained in:
lyavor
2023-01-05 21:26:43 +00:00
parent 3e84685354
commit 4138376416
7 changed files with 30 additions and 7 deletions

View File

@@ -8746,6 +8746,15 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
if (!docLoadInfo->GetLoadErrorPage()) {
if (nsHTTPSOnlyUtils::IsEqualURIExceptSchemeAndRef(
currentExposableURI, aLoadState->URI(), docLoadInfo)) {
// At this point the requested URI is for sure a fragment
// navigation via HTTP and HTTPS-Only mode or HTTPS-First is
// enabled. Since we are on an HTTPS site the fragment
// navigation should also be an HTTPS.
// For that reason we upgrade the URI to HTTPS.
nsCOMPtr<nsIURI> upgradedURI;
NS_GetSecureUpgradedURI(aLoadState->URI(),
getter_AddRefs(upgradedURI));
aLoadState->SetURI(upgradedURI);
aState.mSameExceptHashes = true;
}
}