Skip to content

Instantly share code, notes, and snippets.

@allstarschh
Created April 26, 2017 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allstarschh/e7830dc55dd6e08c52d4e66c4155ff42 to your computer and use it in GitHub Desktop.
Save allstarschh/e7830dc55dd6e08c52d4e66c4155ff42 to your computer and use it in GitHub Desktop.
commit 60ea502145ab255a3d1d5908116e91e5f454ac1a
Author: Yoshi Huang <allstars.chh@mozilla.com>
Date: Fri Apr 7 11:52:27 2017 +0800
Revert "Bug 1334875 - Temporarily remove assertion that history loads pass a valid triggeringprincipal. r=jwatt"
This reverts commit 9f4108a5faa1c84974f7a4cdaaa8d92a689d21ad.
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index 5421c728728e..67bbeffd8a17 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -12669,19 +12669,19 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
if (isSrcdoc) {
aEntry->GetSrcdocData(srcdoc);
aEntry->GetBaseURI(getter_AddRefs(baseURI));
flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
} else {
srcdoc = NullString();
}
- if (!triggeringPrincipal) {
- triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
- }
+ // If there is no valid triggeringPrincipal, we deny the load
+ MOZ_ASSERT(triggeringPrincipal,
+ "need a valid triggeringPrincipal to load from history");
// Passing nullptr as aSourceDocShell gives the same behaviour as before
// aSourceDocShell was introduced. According to spec we should be passing
// the source browsing context that was used when the history entry was
// first created. bug 947716 has been created to address this issue.
rv = InternalLoad(uri,
originalURI,
loadReplace,
diff --git a/docshell/shistory/nsSHEntry.cpp b/docshell/shistory/nsSHEntry.cpp
index 37eaf5e1cfd9..bc04c3f0b4c2 100644
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -521,16 +521,20 @@ nsSHEntry::GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal)
{
NS_IF_ADDREF(*aTriggeringPrincipal = mShared->mTriggeringPrincipal);
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
{
+ MOZ_ASSERT(aTriggeringPrincipal, "need a valid triggeringPrincipal");
+ if (!aTriggeringPrincipal) {
+ return NS_ERROR_FAILURE;
+ }
mShared->mTriggeringPrincipal = aTriggeringPrincipal;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetPrincipalToInherit(nsIPrincipal** aPrincipalToInherit)
{
NS_IF_ADDREF(*aPrincipalToInherit = mShared->mPrincipalToInherit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment