Bug 986439 - Don't use nsNullPrincipalURI for referrer. r=bz

This commit is contained in:
Bob Owen 2014-03-29 19:10:27 +00:00
parent 73eabdd963
commit 5dc254ead5
5 changed files with 27 additions and 3 deletions

View File

@ -6,5 +6,6 @@
EXPORTS += [
'nsJSPrincipals.h',
'nsNullPrincipal.h',
]

View File

@ -15,7 +15,6 @@
#include "nsIPrincipal.h"
#include "nsJSPrincipals.h"
#include "nsCOMPtr.h"
#include "nsPrincipal.h"
#include "nsIContentSecurityPolicy.h"
class nsIURI;

View File

@ -21,6 +21,7 @@
#include "nsNetCID.h"
#include "nsError.h"
#include "nsIScriptSecurityManager.h"
#include "nsPrincipal.h"
#include "nsScriptSecurityManager.h"
#include "pratom.h"

View File

@ -53,6 +53,7 @@
#include "nsIMozBrowserFrame.h"
#include "nsIPermissionManager.h"
#include "nsISHistory.h"
#include "nsNullPrincipal.h"
#include "nsLayoutUtils.h"
#include "nsView.h"
@ -535,7 +536,17 @@ nsFrameLoader::ReallyStartLoadingInternal()
NS_ENSURE_SUCCESS(rv, rv);
}
loadInfo->SetReferrer(referrer);
// Use referrer as long as it is not an nsNullPrincipalURI.
// We could add a method such as GetReferrerURI to principals to make this
// cleaner, but given that we need to start using Source Browsing Context for
// referrer (see Bug 960639) this may be wasted effort at this stage.
if (referrer) {
bool isNullPrincipalScheme;
rv = referrer->SchemeIs(NS_NULLPRINCIPAL_SCHEME, &isNullPrincipalScheme);
if (NS_SUCCEEDED(rv) && !isNullPrincipalScheme) {
loadInfo->SetReferrer(referrer);
}
}
// Default flags:
int32_t flags = nsIWebNavigation::LOAD_FLAGS_NONE;

View File

@ -30,6 +30,7 @@
#include "nsContentUtils.h"
#include "mozilla/Likely.h"
#include "nsCycleCollectionParticipant.h"
#include "nsNullPrincipal.h"
#include "ScriptSettings.h"
static nsresult
@ -145,7 +146,18 @@ nsLocation::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
sourceURI = docCurrentURI;
}
else {
sourceURI = principalURI;
// Use principalURI as long as it is not an nsNullPrincipalURI.
// We could add a method such as GetReferrerURI to principals to make this
// cleaner, but given that we need to start using Source Browsing Context
// for referrer (see Bug 960639) this may be wasted effort at this stage.
if (principalURI) {
bool isNullPrincipalScheme;
rv = principalURI->SchemeIs(NS_NULLPRINCIPAL_SCHEME,
&isNullPrincipalScheme);
if (NS_SUCCEEDED(rv) && !isNullPrincipalScheme) {
sourceURI = principalURI;
}
}
}
owner = do_QueryInterface(ssm->GetCxSubjectPrincipal(cx));