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
--- 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)
{