Bug 1458449 - Allow FTP subresource in FTP documents. r=ckerschb

--HG--
extra : rebase_source : 035bd3782abb6deeff4aaf1d227ce7197f9234a6
This commit is contained in:
Tom Schuster 2018-05-02 13:32:08 +02:00
Родитель 08e964fd73
Коммит 5a642e8bf6
1 изменённых файлов: 9 добавлений и 1 удалений

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

@ -162,7 +162,7 @@ nsContentSecurityManager::AllowInsecureRedirectToDataURI(nsIChannel* aNewChannel
/* static */ nsresult
nsContentSecurityManager::CheckFTPSubresourceLoad(nsIChannel* aChannel)
{
// We dissallow using FTP resources as a subresource everywhere.
// We dissallow using FTP resources as a subresource almost everywhere.
// The only valid way to use FTP resources is loading it as
// a top level document.
if (!mozilla::net::nsIOService::BlockFTPSubresources()) {
@ -191,6 +191,14 @@ nsContentSecurityManager::CheckFTPSubresourceLoad(nsIChannel* aChannel)
return NS_OK;
}
// Allow loading FTP subresources in FTP documents, like XML.
nsIPrincipal* triggeringPrincipal = loadInfo->TriggeringPrincipal();
nsCOMPtr<nsIURI> triggeringURI;
triggeringPrincipal->GetURI(getter_AddRefs(triggeringURI));
if (triggeringURI && nsContentUtils::SchemeIs(triggeringURI, "ftp")) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc;
if (nsINode* node = loadInfo->LoadingNode()) {
doc = node->OwnerDoc();