Bug 1469536 - Allow the system principal to load FTP subresources. r=ckerschb, a=RyanVM
authorTom Schuster <evilpies@gmail.com>
Tue, 19 Jun 2018 13:58:41 +0200
changeset 473781 5afdaceeb96a3b80edeed5cff5ef917716f90b9d
parent 473780 f5ea361ceb75d5cdb9c44112ae6d37117b05e626
child 473782 61ce1b424ccca62c4269c46006d115f2aeb082bc
push id1732
push userjcristau@mozilla.com
push dateThu, 21 Jun 2018 12:56:25 +0000
treeherdermozilla-release@785d242a5b01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb, RyanVM
bugs1469536
milestone61.0
Bug 1469536 - Allow the system principal to load FTP subresources. r=ckerschb, a=RyanVM
dom/security/nsContentSecurityManager.cpp
--- a/dom/security/nsContentSecurityManager.cpp
+++ b/dom/security/nsContentSecurityManager.cpp
@@ -174,30 +174,36 @@ nsContentSecurityManager::CheckFTPSubres
     return NS_OK;
   }
 
   nsContentPolicyType type = loadInfo->GetExternalContentPolicyType();
   if (type == nsIContentPolicy::TYPE_DOCUMENT) {
     return NS_OK;
   }
 
+  // Allow the system principal to load everything. This is meant to
+  // temporarily fix downloads and pdf.js.
+  nsIPrincipal* triggeringPrincipal = loadInfo->TriggeringPrincipal();
+  if (nsContentUtils::IsSystemPrincipal(triggeringPrincipal)) {
+    return NS_OK;
+  }
+
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
   if (!uri) {
     return NS_OK;
   }
 
   bool isFtpURI = (NS_SUCCEEDED(uri->SchemeIs("ftp", &isFtpURI)) && isFtpURI);
   if (!isFtpURI) {
     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()) {