зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1309310, r=bz
MozReview-Commit-ID: KLaMv6zfxR8 --HG-- extra : rebase_source : ccb4d19c874230c512010d3891aae33a69947f62
This commit is contained in:
Родитель
6c920ce172
Коммит
82d475be93
|
@ -803,15 +803,27 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
|||
nsCaseInsensitiveCStringComparator stringComparator;
|
||||
nsCOMPtr<nsIURI> currentURI = sourceURI;
|
||||
nsCOMPtr<nsIURI> currentOtherURI = aTargetURI;
|
||||
|
||||
bool denySameSchemeLinks = false;
|
||||
rv = NS_URIChainHasFlags(aTargetURI, nsIProtocolHandler::URI_SCHEME_NOT_SELF_LINKABLE,
|
||||
&denySameSchemeLinks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
while (currentURI && currentOtherURI) {
|
||||
nsAutoCString scheme, otherScheme;
|
||||
currentURI->GetScheme(scheme);
|
||||
currentOtherURI->GetScheme(otherScheme);
|
||||
|
||||
// If schemes are not equal, check if the URI flags of the current
|
||||
// target URI allow the current source URI to link to it.
|
||||
// If schemes are not equal, or they're equal but the target URI
|
||||
// is different from the source URI and doesn't always allow linking
|
||||
// from the same scheme, check if the URI flags of the current target
|
||||
// URI allow the current source URI to link to it.
|
||||
// The policy is specified by the protocol flags on both URIs.
|
||||
if (!scheme.Equals(otherScheme, stringComparator)) {
|
||||
bool equalExceptRef = false;
|
||||
if (!scheme.Equals(otherScheme, stringComparator) ||
|
||||
(denySameSchemeLinks &&
|
||||
(!NS_SUCCEEDED(currentURI->EqualsExceptRef(currentOtherURI, &equalExceptRef)) ||
|
||||
!equalExceptRef))) {
|
||||
return CheckLoadURIFlags(currentURI, currentOtherURI,
|
||||
sourceBaseURI, targetBaseURI, aFlags);
|
||||
}
|
||||
|
|
|
@ -300,6 +300,12 @@ interface nsIProtocolHandler : nsISupports
|
|||
* spec, not just the scheme + host + port.
|
||||
*/
|
||||
const unsigned long ORIGIN_IS_FULL_SPEC = (1 << 20);
|
||||
|
||||
/**
|
||||
* If this flag is set, the URI does not always allow content using the same
|
||||
* protocol to link to it.
|
||||
*/
|
||||
const unsigned long URI_SCHEME_NOT_SELF_LINKABLE = (1 << 21);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -67,7 +67,7 @@ nsAboutProtocolHandler::GetDefaultPort(int32_t *result)
|
|||
NS_IMETHODIMP
|
||||
nsAboutProtocolHandler::GetProtocolFlags(uint32_t *result)
|
||||
{
|
||||
*result = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD;
|
||||
*result = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD | URI_SCHEME_NOT_SELF_LINKABLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче