Bug 1847918 - Limit nsDocShellLoadState::IsExemptFromHTTPSOnlyMode to HTTPS-First r=freddyb

`nsDocShellLoadState::IsExemptFromHTTPSOnlyMode` is currently only used by HTTPS-First. It is used for fixing upgrade-downgrade loops and when loading history entries, as when we already know if HTTPS-First succeeded there or not, we have no need for trying to upgrade again and can disable HTTPS-First. With the changes introduced by Bug 1839612, `nsDocShellLoadState::IsExemptFromHTTPSOnlyMode` also applies to HTTPS-Only, which is a problem because disabling HTTPS-Only for history entries will result in them potentially being loaded insecurely without the user setting an exception. As a solution this patch just applies `nsILoadInfo::HTTPS_ONLY_EXEMPT_NEXT_LOAD`, the flag being set when `nsDocShellLoadState::IsExemptFromHTTPSOnlyMode` is set, when HTTPS-First is enabled, and renames both flags to reflect that behavior.

Differential Revision: https://phabricator.services.mozilla.com/D185829
This commit is contained in:
Malte Juergens
2023-09-11 12:14:30 +00:00
parent 95753f146b
commit e9b9c95fe2
13 changed files with 139 additions and 24 deletions

View File

@@ -62,7 +62,7 @@ nsDocShellLoadState::nsDocShellLoadState(
mInheritPrincipal = aLoadState.InheritPrincipal();
mPrincipalIsExplicit = aLoadState.PrincipalIsExplicit();
mForceAllowDataURI = aLoadState.ForceAllowDataURI();
mIsExemptFromHTTPSOnlyMode = aLoadState.IsExemptFromHTTPSOnlyMode();
mIsExemptFromHTTPSFirstMode = aLoadState.IsExemptFromHTTPSFirstMode();
mOriginalFrameSrc = aLoadState.OriginalFrameSrc();
mIsFormSubmission = aLoadState.IsFormSubmission();
mLoadType = aLoadState.LoadType();
@@ -163,7 +163,7 @@ nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther)
mPrincipalToInherit(aOther.mPrincipalToInherit),
mPartitionedPrincipalToInherit(aOther.mPartitionedPrincipalToInherit),
mForceAllowDataURI(aOther.mForceAllowDataURI),
mIsExemptFromHTTPSOnlyMode(aOther.mIsExemptFromHTTPSOnlyMode),
mIsExemptFromHTTPSFirstMode(aOther.mIsExemptFromHTTPSFirstMode),
mOriginalFrameSrc(aOther.mOriginalFrameSrc),
mIsFormSubmission(aOther.mIsFormSubmission),
mLoadType(aOther.mLoadType),
@@ -216,7 +216,7 @@ nsDocShellLoadState::nsDocShellLoadState(nsIURI* aURI, uint64_t aLoadIdentifier)
mPrincipalIsExplicit(false),
mNotifiedBeforeUnloadListeners(false),
mForceAllowDataURI(false),
mIsExemptFromHTTPSOnlyMode(false),
mIsExemptFromHTTPSFirstMode(false),
mOriginalFrameSrc(false),
mIsFormSubmission(false),
mLoadType(LOAD_NORMAL),
@@ -619,13 +619,13 @@ void nsDocShellLoadState::SetForceAllowDataURI(bool aForceAllowDataURI) {
mForceAllowDataURI = aForceAllowDataURI;
}
bool nsDocShellLoadState::IsExemptFromHTTPSOnlyMode() const {
return mIsExemptFromHTTPSOnlyMode;
bool nsDocShellLoadState::IsExemptFromHTTPSFirstMode() const {
return mIsExemptFromHTTPSFirstMode;
}
void nsDocShellLoadState::SetIsExemptFromHTTPSOnlyMode(
bool aIsExemptFromHTTPSOnlyMode) {
mIsExemptFromHTTPSOnlyMode = aIsExemptFromHTTPSOnlyMode;
void nsDocShellLoadState::SetIsExemptFromHTTPSFirstMode(
bool aIsExemptFromHTTPSFirstMode) {
mIsExemptFromHTTPSFirstMode = aIsExemptFromHTTPSFirstMode;
}
bool nsDocShellLoadState::OriginalFrameSrc() const { return mOriginalFrameSrc; }
@@ -1256,7 +1256,7 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize(
loadState.InheritPrincipal() = mInheritPrincipal;
loadState.PrincipalIsExplicit() = mPrincipalIsExplicit;
loadState.ForceAllowDataURI() = mForceAllowDataURI;
loadState.IsExemptFromHTTPSOnlyMode() = mIsExemptFromHTTPSOnlyMode;
loadState.IsExemptFromHTTPSFirstMode() = mIsExemptFromHTTPSFirstMode;
loadState.OriginalFrameSrc() = mOriginalFrameSrc;
loadState.IsFormSubmission() = mIsFormSubmission;
loadState.LoadType() = mLoadType;