mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 20:01:50 +00:00
Bug 1840647 - Part 2: Stop using GetWebExposedOriginSerialization in imgLoader, r=tnikkel
The current behaviour would treat all null principals as the same, and is using an extra comparison for origin attributes explicitly in addition to the web exposed origin serialization. As far as I can tell, this will never be called with a null `aPrincipal`, but I figured it was worth fixing. This changes the logic to use full principals for comparison, rather than serializing to strings. Differential Revision: https://phabricator.services.mozilla.com/D182227
This commit is contained in:
parent
17a0d2d6fe
commit
d02de7ba99
@ -1410,15 +1410,6 @@ nsresult imgLoader::RemoveEntriesInternal(nsIPrincipal* aPrincipal,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAutoString origin;
|
||||
if (aPrincipal) {
|
||||
nsresult rv =
|
||||
nsContentUtils::GetWebExposedOriginSerialization(aPrincipal, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEffectiveTLDService> tldService;
|
||||
AutoTArray<RefPtr<imgCacheEntry>, 128> entriesToBeRemoved;
|
||||
|
||||
@ -1428,19 +1419,10 @@ nsresult imgLoader::RemoveEntriesInternal(nsIPrincipal* aPrincipal,
|
||||
|
||||
const bool shouldRemove = [&] {
|
||||
if (aPrincipal) {
|
||||
if (key.OriginAttributesRef() !=
|
||||
BasePrincipal::Cast(aPrincipal)->OriginAttributesRef()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString imageOrigin;
|
||||
nsresult rv = nsContentUtils::GetWebExposedOriginSerialization(
|
||||
key.URI(), imageOrigin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return imageOrigin == origin;
|
||||
nsCOMPtr<nsIPrincipal> keyPrincipal =
|
||||
BasePrincipal::CreateContentPrincipal(key.URI(),
|
||||
key.OriginAttributesRef());
|
||||
return keyPrincipal->Equals(aPrincipal);
|
||||
}
|
||||
|
||||
if (!aBaseDomain) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user