MozReview-Commit-ID: KLaMv6zfxR8

--HG--
extra : rebase_source : ccb4d19c874230c512010d3891aae33a69947f62
This commit is contained in:
Gijs Kruitbosch 2016-11-09 18:25:11 +00:00
Родитель 6c920ce172
Коммит 82d475be93
3 изменённых файлов: 22 добавлений и 4 удалений

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

@ -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;
}