diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/components/antitracking/StoragePrincipalHelper.cpp | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/antitracking/StoragePrincipalHelper.cpp')
-rw-r--r-- | toolkit/components/antitracking/StoragePrincipalHelper.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/toolkit/components/antitracking/StoragePrincipalHelper.cpp b/toolkit/components/antitracking/StoragePrincipalHelper.cpp index 10be1112ca..79bafead2c 100644 --- a/toolkit/components/antitracking/StoragePrincipalHelper.cpp +++ b/toolkit/components/antitracking/StoragePrincipalHelper.cpp @@ -86,8 +86,10 @@ bool ChooseOriginAttributes(nsIChannel* aChannel, OriginAttributes& aAttrs, if (NS_WARN_IF(NS_FAILED(rv))) { return false; } - - aAttrs.SetPartitionKey(principalURI); + bool foreignByAncestorContext = + AntiTrackingUtils::IsThirdPartyChannel(aChannel) && + !loadInfo->GetIsThirdPartyContextToTopWindow(); + aAttrs.SetPartitionKey(principalURI, foreignByAncestorContext); return true; } @@ -313,7 +315,7 @@ nsresult StoragePrincipalHelper::GetPrincipal(nsIChannel* aChannel, // We only support foreign partitioned principal when dFPI is enabled. if (cjs->GetCookieBehavior() == nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN && - loadInfo->GetIsThirdPartyContextToTopWindow()) { + AntiTrackingUtils::IsThirdPartyChannel(aChannel)) { outPrincipal = partitionedPrincipal; } break; @@ -435,7 +437,7 @@ bool StoragePrincipalHelper::ShouldUsePartitionPrincipalForServiceWorker( return false; } - return aWorkerPrivate->IsThirdPartyContextToTopWindow(); + return aWorkerPrivate->IsThirdPartyContext(); } // static @@ -479,7 +481,7 @@ bool StoragePrincipalHelper::GetOriginAttributes( // Otherwise, we will use the regular principal. if (cjs->GetCookieBehavior() == nsICookieService::BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN && - loadInfo->GetIsThirdPartyContextToTopWindow()) { + AntiTrackingUtils::IsThirdPartyChannel(aChannel)) { ChooseOriginAttributes(aChannel, aAttributes, true); } break; @@ -560,7 +562,7 @@ void StoragePrincipalHelper::UpdateOriginAttributesForNetworkState( return; } - aAttributes.SetPartitionKey(aFirstPartyURI); + aAttributes.SetPartitionKey(aFirstPartyURI, false); } enum SupportedScheme { HTTP, HTTPS }; @@ -664,8 +666,9 @@ bool StoragePrincipalHelper::PartitionKeyHasBaseDomain( nsString scheme; nsString pkBaseDomain; int32_t port; - bool success = OriginAttributes::ParsePartitionKey(aPartitionKey, scheme, - pkBaseDomain, port); + bool foreign; + bool success = OriginAttributes::ParsePartitionKey( + aPartitionKey, scheme, pkBaseDomain, port, foreign); if (!success) { return false; @@ -674,4 +677,26 @@ bool StoragePrincipalHelper::PartitionKeyHasBaseDomain( return aBaseDomain.Equals(pkBaseDomain); } +// static +void StoragePrincipalHelper::UpdatePartitionKeyWithForeignAncestorBit( + nsAString& aKey, bool aForeignByAncestorContext) { + bool site = 0 == aKey.Find(u"("); + if (!site) { + return; + } + if (aForeignByAncestorContext) { + int32_t index = aKey.Find(u",f)"); + if (index == -1) { + uint32_t cutStart = aKey.Length() - 1; + aKey.ReplaceLiteral(cutStart, 1, u",f)"); + } + } else { + int32_t index = aKey.Find(u",f)"); + if (index != -1) { + uint32_t cutLength = aKey.Length() - index; + aKey.ReplaceLiteral(index, cutLength, u")"); + } + } +} + } // namespace mozilla |