Bug 1473507 - fix crash in nsILoadInfo::GetOriginAttributes when passing no principal to SavePrivacyAwareURI, r=mccr8
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 05 Jul 2018 23:50:45 +0100
changeset 425262 ddb29b481834c16a608ff6e4dd8382155239a94f
parent 425261 8a7fd632104453b557ca73a335626d4f24427b50
child 425263 de7abe2c2b3e8713aef98947b8cb784e4628c009
push id34241
push userebalazs@mozilla.com
push dateFri, 06 Jul 2018 09:45:16 +0000
treeherdermozilla-central@80d8f267abd8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1473507
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)
     {