Bug 1473507 - fix crash in nsILoadInfo::GetOriginAttributes when passing no principal to SavePrivacyAwareURI, r?mccr8 draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 05 Jul 2018 23:50:45 +0100
changeset 814708 67072d98a9f2dc303b0863cfa5fc41a2210b3cca
parent 814073 a9dc5dc8e2b8513686ad1b1f28c9e4da6de62226
push id115318
push userbmo:gijskruitbosch+bugs@gmail.com
push dateThu, 05 Jul 2018 23:17:22 +0000
reviewersmccr8
bugs1473507
milestone63.0a1
Bug 1473507 - fix crash in nsILoadInfo::GetOriginAttributes when passing no principal to SavePrivacyAwareURI, r?mccr8 Enforce that callers pass triggering principals through to any persist APIs, which all delegate to SaveURIInternal. Also add the missing principal information to the saveURL call in the page info dialog code, which was triggering crashes in this way. MozReview-Commit-ID: L9pNE7BxGws
browser/base/content/pageinfo/pageInfo.js
dom/webbrowserpersist/nsWebBrowserPersist.cpp
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -676,17 +676,17 @@ function saveMedia() {
       var titleKey = "SaveImageTitle";
 
       if (item instanceof HTMLVideoElement)
         titleKey = "SaveVideoTitle";
       else if (item instanceof HTMLAudioElement)
         titleKey = "SaveAudioTitle";
 
       saveURL(url, null, titleKey, false, false, makeURI(item.baseURI),
-              null, gDocInfo.isContentWindowPrivate);
+              null, gDocInfo.isContentWindowPrivate, gDocInfo.principal);
     }
   } else {
     selectSaveFolder(function(aDirectory) {
       if (aDirectory) {
         var saveAnImage = function(aURIString, aChosenData, aBaseURI) {
           uniqueFile(aChosenData.file);
           internalSave(aURIString, null, null, null, null, false, "SaveImageTitle",
                        aChosenData, aBaseURI, null, false, null,
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -1337,16 +1337,17 @@ nsresult nsWebBrowserPersist::SaveURIInt
     nsIURI *aURI, nsIPrincipal* aTriggeringPrincipal,
     uint32_t aCacheKey, nsIURI *aReferrer,
     uint32_t aReferrerPolicy, nsIInputStream *aPostData,
     const char *aExtraHeaders, nsIURI *aFile,
     bool aCalcFileExt, bool aIsPrivate)
 {
     NS_ENSURE_ARG_POINTER(aURI);
     NS_ENSURE_ARG_POINTER(aFile);
+    NS_ENSURE_ARG_POINTER(aTriggeringPrincipal);
 
     nsresult rv = NS_OK;
 
     mURI = aURI;
 
     nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
     if (mPersistFlags & PERSIST_FLAGS_BYPASS_CACHE)
     {