Bug 1054646 - Part 1: Change nsNullPrincipal::CheckMayLoad to always allow loads when the principal of the URI in the principal doing the load. r=bz

This commit is contained in:
Bob Owen 2014-09-30 09:09:36 +01:00
Родитель 3db6a4453b
Коммит 3140b4a353
2 изменённых файлов: 11 добавлений и 16 удалений

Просмотреть файл

@ -113,13 +113,9 @@ interface nsIPrincipal : nsISerializable
* located at the given URI under the same-origin policy. This means that
* codebase principals are only allowed to load resources from the same
* domain, the system principal is allowed to load anything, and null
* principals are not allowed to load anything. This is changed slightly
* by the optional flag allowIfInheritsPrincipal (which defaults to false)
* which allows the load of a data: URI (which inherits the principal of
* its loader) or a URI with the same principal as its loader (eg. a
* Blob URI).
* In these cases, with allowIfInheritsPrincipal set to true, the URI can
* be loaded by a null principal.
* principals can only load URIs where they are the principal. This is
* changed by the optional flag allowIfInheritsPrincipal (which defaults to
* false) which allows URIs that inherit their loader's principal.
*
* If the load is allowed this function does nothing. If the load is not
* allowed the function throws NS_ERROR_DOM_BAD_URI.

Просмотреть файл

@ -239,17 +239,16 @@ nsNullPrincipal::CheckMayLoad(nsIURI* aURI, bool aReport, bool aAllowIfInheritsP
if (nsPrincipal::IsPrincipalInherited(aURI)) {
return NS_OK;
}
}
// Also allow the load if the principal of the URI being checked is exactly
// us ie this.
nsCOMPtr<nsIURIWithPrincipal> uriPrinc = do_QueryInterface(aURI);
if (uriPrinc) {
nsCOMPtr<nsIPrincipal> principal;
uriPrinc->GetPrincipal(getter_AddRefs(principal));
// Also allow the load if we are the principal of the URI being checked.
nsCOMPtr<nsIURIWithPrincipal> uriPrinc = do_QueryInterface(aURI);
if (uriPrinc) {
nsCOMPtr<nsIPrincipal> principal;
uriPrinc->GetPrincipal(getter_AddRefs(principal));
if (principal && principal == this) {
return NS_OK;
}
if (principal == this) {
return NS_OK;
}
}