mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 327244 (2/2) - Remove nsIScriptSecurityManager::CheckLoadURI(). r=sicking,jlebar
This commit is contained in:
parent
32d220e324
commit
8a2133a405
@ -84,21 +84,6 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager
|
||||
in nsIURI uri,
|
||||
in unsigned long flags);
|
||||
|
||||
/**
|
||||
* Check that content from "from" can load "uri".
|
||||
*
|
||||
* Will return error code NS_ERROR_DOM_BAD_URI if the load request
|
||||
* should be denied.
|
||||
*
|
||||
* @param from the URI causing the load
|
||||
* @param uri the URI that is being loaded
|
||||
* @param flags the permission set, see above
|
||||
*
|
||||
* @deprecated Use checkLoadURIWithPrincipal instead of this function.
|
||||
*/
|
||||
[deprecated] void checkLoadURI(in nsIURI from, in nsIURI uri,
|
||||
in unsigned long flags);
|
||||
|
||||
/**
|
||||
* Similar to checkLoadURIWithPrincipal but there are two differences:
|
||||
*
|
||||
|
@ -1262,25 +1262,6 @@ nsScriptSecurityManager::CheckLoadURIFromScript(JSContext *cx, nsIURI *aURI)
|
||||
return NS_ERROR_DOM_BAD_URI;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptSecurityManager::CheckLoadURI(nsIURI *aSourceURI, nsIURI *aTargetURI,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
// FIXME: bug 327244 -- this function should really die... Really truly.
|
||||
NS_PRECONDITION(aSourceURI, "CheckLoadURI called with null source URI");
|
||||
NS_ENSURE_ARG_POINTER(aSourceURI);
|
||||
|
||||
// Note: this is not _quite_ right if aSourceURI has
|
||||
// NS_NULLPRINCIPAL_SCHEME, but we'll just extract the scheme in
|
||||
// CheckLoadURIWithPrincipal anyway, so this is good enough. This method
|
||||
// really needs to go away....
|
||||
nsCOMPtr<nsIPrincipal> sourcePrincipal;
|
||||
nsresult rv = CreateCodebasePrincipal(aSourceURI,
|
||||
getter_AddRefs(sourcePrincipal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return CheckLoadURIWithPrincipal(sourcePrincipal, aTargetURI, aFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to handle cases where a flag passed to
|
||||
* CheckLoadURIWithPrincipal means denying loading if the given URI has certain
|
||||
|
@ -3087,7 +3087,7 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData)
|
||||
// should really be the same thing). Note that this code can run
|
||||
// before the current URI of the webnavigation has been updated, so we
|
||||
// can't assert equality here.
|
||||
refresher->SetupRefreshURIFromHeader(mDocumentURI,
|
||||
refresher->SetupRefreshURIFromHeader(mDocumentURI, NodePrincipal(),
|
||||
NS_ConvertUTF16toUTF8(aData));
|
||||
}
|
||||
}
|
||||
|
@ -241,6 +241,7 @@ txMozillaXMLOutput::endDocument(nsresult aResult)
|
||||
do_QueryInterface(win->GetDocShell());
|
||||
if (refURI) {
|
||||
refURI->SetupRefreshURIFromHeader(mDocument->GetDocBaseURI(),
|
||||
mDocument->NodePrincipal(),
|
||||
mRefreshString);
|
||||
}
|
||||
}
|
||||
|
@ -5528,6 +5528,7 @@ nsDocShell::ForceRefreshURI(nsIURI * aURI,
|
||||
|
||||
nsresult
|
||||
nsDocShell::SetupRefreshURIFromHeader(nsIURI * aBaseURI,
|
||||
nsIPrincipal* aPrincipal,
|
||||
const nsACString & aHeader)
|
||||
{
|
||||
// Refresh headers are parsed with the following format in mind
|
||||
@ -5569,6 +5570,8 @@ nsDocShell::SetupRefreshURIFromHeader(nsIURI * aBaseURI,
|
||||
|
||||
// when done, seconds is 0 or the given number of seconds
|
||||
// uriAttrib is empty or the URI specified
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
nsCAutoString uriAttrib;
|
||||
PRInt32 seconds = 0;
|
||||
bool specifiesSeconds = false;
|
||||
@ -5733,9 +5736,8 @@ nsDocShell::SetupRefreshURIFromHeader(nsIURI * aBaseURI,
|
||||
(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = securityManager->
|
||||
CheckLoadURI(aBaseURI, uri,
|
||||
nsIScriptSecurityManager::
|
||||
LOAD_IS_AUTOMATIC_DOCUMENT_REPLACEMENT);
|
||||
CheckLoadURIWithPrincipal(aPrincipal, uri,
|
||||
nsIScriptSecurityManager::LOAD_IS_AUTOMATIC_DOCUMENT_REPLACEMENT);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
bool isjs = true;
|
||||
@ -5771,8 +5773,16 @@ NS_IMETHODIMP nsDocShell::SetupRefreshURI(nsIChannel * aChannel)
|
||||
refreshHeader);
|
||||
|
||||
if (!refreshHeader.IsEmpty()) {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = secMan->GetChannelPrincipal(aChannel, getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
SetupReferrerFromChannel(aChannel);
|
||||
rv = SetupRefreshURIFromHeader(mCurrentURI, refreshHeader);
|
||||
rv = SetupRefreshURIFromHeader(mCurrentURI, principal, refreshHeader);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return NS_REFRESHURI_HEADER_FOUND;
|
||||
}
|
||||
|
@ -7,8 +7,9 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIURI.idl"
|
||||
interface nsIChannel;
|
||||
interface nsIPrincipal;
|
||||
|
||||
[scriptable, uuid(cb0ad623-6b46-4c09-a473-c1d6ca63d3c7)]
|
||||
[scriptable, uuid(a5e61a3c-51bd-45be-ac0c-e87b71860656)]
|
||||
interface nsIRefreshURI : nsISupports {
|
||||
/**
|
||||
* Load a uri after waiting for aMillis milliseconds. If the docshell
|
||||
@ -55,10 +56,11 @@ interface nsIRefreshURI : nsISupports {
|
||||
* the current page finishes loading.
|
||||
*
|
||||
* @param aBaseURI base URI to resolve refresh uri with.
|
||||
* @param principal the associated principal
|
||||
* @param aHeader The meta refresh header string.
|
||||
*/
|
||||
void setupRefreshURIFromHeader(in nsIURI aBaseURI, in ACString aHeader);
|
||||
|
||||
void setupRefreshURIFromHeader(in nsIURI aBaseURI, in nsIPrincipal principal, in ACString aHeader);
|
||||
|
||||
/**
|
||||
* Cancels all timer loads.
|
||||
*/
|
||||
|
@ -713,14 +713,6 @@ FullTrustSecMan::CheckLoadURIWithPrincipal(nsIPrincipal *aPrincipal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FullTrustSecMan::CheckLoadURI(nsIURI *from,
|
||||
nsIURI *uri,
|
||||
PRUint32 flags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FullTrustSecMan::CheckLoadURIStrWithPrincipal(nsIPrincipal *aPrincipal,
|
||||
const nsACString & uri,
|
||||
|
@ -1332,13 +1332,6 @@ FullTrustSecMan::CheckLoadURIWithPrincipal(nsIPrincipal *aPrincipal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void checkLoadURI (in nsIURI from, in nsIURI uri, in unsigned long flags); */
|
||||
NS_IMETHODIMP
|
||||
FullTrustSecMan::CheckLoadURI(nsIURI *from, nsIURI *uri, PRUint32 flags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void checkLoadURIStrWithPrincipal (in nsIPrincipal aPrincipal, in AUTF8String uri, in unsigned long flags); */
|
||||
NS_IMETHODIMP
|
||||
FullTrustSecMan::CheckLoadURIStrWithPrincipal(nsIPrincipal *aPrincipal,
|
||||
|
@ -809,12 +809,14 @@ function ReadManifest(aURL, inherited_status)
|
||||
}
|
||||
}
|
||||
|
||||
var principal = secMan.getCodebasePrincipal(aURL);
|
||||
|
||||
if (items[0] == "include") {
|
||||
if (items.length != 2 || runHttp)
|
||||
throw "Error 2 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var incURI = gIOService.newURI(items[1], null, listURL);
|
||||
secMan.checkLoadURI(aURL, incURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURIWithPrincipal(principal, incURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
ReadManifest(incURI, expected_status);
|
||||
} else if (items[0] == TYPE_LOAD) {
|
||||
if (items.length != 2 ||
|
||||
@ -822,14 +824,14 @@ function ReadManifest(aURL, inherited_status)
|
||||
expected_status != EXPECTED_DEATH))
|
||||
throw "Error 3 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var [testURI] = runHttp
|
||||
? ServeFiles(aURL, httpDepth,
|
||||
? ServeFiles(principal, httpDepth,
|
||||
listURL, [items[1]])
|
||||
: [gIOService.newURI(items[1], null, listURL)];
|
||||
var prettyPath = runHttp
|
||||
? gIOService.newURI(items[1], null, listURL).spec
|
||||
: testURI.spec;
|
||||
secMan.checkLoadURI(aURL, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURIWithPrincipal(principal, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
gURLs.push( { type: TYPE_LOAD,
|
||||
expected: expected_status,
|
||||
allowSilentFail: allow_silent_fail,
|
||||
@ -848,14 +850,14 @@ function ReadManifest(aURL, inherited_status)
|
||||
if (items.length != 2)
|
||||
throw "Error 4 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var [testURI] = runHttp
|
||||
? ServeFiles(aURL, httpDepth,
|
||||
? ServeFiles(principal, httpDepth,
|
||||
listURL, [items[1]])
|
||||
: [gIOService.newURI(items[1], null, listURL)];
|
||||
var prettyPath = runHttp
|
||||
? gIOService.newURI(items[1], null, listURL).spec
|
||||
: testURI.spec;
|
||||
secMan.checkLoadURI(aURL, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURIWithPrincipal(principal, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
gURLs.push( { type: TYPE_SCRIPT,
|
||||
expected: expected_status,
|
||||
allowSilentFail: allow_silent_fail,
|
||||
@ -874,17 +876,17 @@ function ReadManifest(aURL, inherited_status)
|
||||
if (items.length != 3)
|
||||
throw "Error 5 in manifest file " + aURL.spec + " line " + lineNo;
|
||||
var [testURI, refURI] = runHttp
|
||||
? ServeFiles(aURL, httpDepth,
|
||||
? ServeFiles(principal, httpDepth,
|
||||
listURL, [items[1], items[2]])
|
||||
: [gIOService.newURI(items[1], null, listURL),
|
||||
gIOService.newURI(items[2], null, listURL)];
|
||||
var prettyPath = runHttp
|
||||
? gIOService.newURI(items[1], null, listURL).spec
|
||||
: testURI.spec;
|
||||
secMan.checkLoadURI(aURL, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURI(aURL, refURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURIWithPrincipal(principal, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURIWithPrincipal(principal, refURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
gURLs.push( { type: items[0],
|
||||
expected: expected_status,
|
||||
allowSilentFail: allow_silent_fail,
|
||||
@ -936,7 +938,7 @@ function BuildUseCounts()
|
||||
}
|
||||
}
|
||||
|
||||
function ServeFiles(manifestURL, depth, aURL, files)
|
||||
function ServeFiles(manifestPrincipal, depth, aURL, files)
|
||||
{
|
||||
var listURL = aURL.QueryInterface(CI.nsIFileURL);
|
||||
var directory = listURL.file.parent;
|
||||
@ -968,8 +970,8 @@ function ServeFiles(manifestURL, depth, aURL, files)
|
||||
var testURI = gIOService.newURI(file, null, testbase);
|
||||
|
||||
// XXX necessary? manifestURL guaranteed to be file, others always HTTP
|
||||
secMan.checkLoadURI(manifestURL, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
secMan.checkLoadURIWithPrincipal(manifestPrincipal, testURI,
|
||||
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
||||
|
||||
return testURI;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user