mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1534538 - Principal serialization should not serialize base domain if not needed, r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D24710 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6a4e37ae32
commit
ac66f432bc
@ -206,7 +206,8 @@ nsresult PopulateContentSecurityPolicies(
|
||||
}
|
||||
|
||||
nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
PrincipalInfo* aPrincipalInfo) {
|
||||
PrincipalInfo* aPrincipalInfo,
|
||||
bool aSkipBaseDomain) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
MOZ_ASSERT(aPrincipalInfo);
|
||||
@ -248,7 +249,7 @@ nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
PrincipalInfo info;
|
||||
|
||||
for (auto& prin : expanded->AllowList()) {
|
||||
rv = PrincipalToPrincipalInfo(prin, &info);
|
||||
rv = PrincipalToPrincipalInfo(prin, &info, aSkipBaseDomain);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -313,9 +314,13 @@ nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
|
||||
// This attribute is not crucial.
|
||||
nsCString baseDomain;
|
||||
if (NS_FAILED(aPrincipal->GetBaseDomain(baseDomain))) {
|
||||
NS_WARNING("Failed to get base domain!");
|
||||
if (aSkipBaseDomain) {
|
||||
baseDomain.SetIsVoid(true);
|
||||
} else {
|
||||
if (NS_FAILED(aPrincipal->GetBaseDomain(baseDomain))) {
|
||||
NS_WARNING("Failed to get base domain!");
|
||||
baseDomain.SetIsVoid(true);
|
||||
}
|
||||
}
|
||||
|
||||
*aPrincipalInfo =
|
||||
|
@ -80,7 +80,8 @@ nsresult PopulateContentSecurityPolicies(
|
||||
* MUST be called on the main thread only.
|
||||
*/
|
||||
nsresult PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
PrincipalInfo* aPrincipalInfo);
|
||||
PrincipalInfo* aPrincipalInfo,
|
||||
bool aSkipBaseDomain = false);
|
||||
|
||||
/**
|
||||
* Return true if this PrincipalInfo is a content principal and it has
|
||||
|
@ -167,7 +167,8 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
|
||||
}
|
||||
|
||||
PrincipalInfo principalInfo;
|
||||
rv = PrincipalToPrincipalInfo(principal, &principalInfo);
|
||||
rv = PrincipalToPrincipalInfo(principal, &principalInfo,
|
||||
true /* aSkipBaseDomain */);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user