Bug 172372, when loading XML as data, we need to disable scripts and styles. r=sicking, sr=bzbarsky, a=asa.

git-svn-id: svn://10.0.0.236/trunk@131749 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
heikki%netscape.com
2002-10-11 00:38:29 +00:00
parent 6d36025452
commit 5bee27e8e8
13 changed files with 207 additions and 84 deletions

View File

@@ -125,6 +125,8 @@
static char kNameSpaceSeparator = ':';
#define kXSLType "text/xsl"
static const char* kLoadAsData = "loadAsData";
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
@@ -854,6 +856,11 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
nsresult rv = NS_OK;
mPrettyPrintXML = PR_FALSE;
nsAutoString cmd;
if (mParser) mParser->GetCommand(cmd);
if (cmd.EqualsWithConversion(kLoadAsData))
return NS_OK; // Do not load stylesheets when loading as data
if (aType.EqualsIgnoreCase(kXSLType) ||
aType.EqualsIgnoreCase(kXMLTextContentType) ||
aType.EqualsIgnoreCase(kXMLApplicationContentType)) {

View File

@@ -469,6 +469,32 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
PRBool aReset,
nsIContentSink* aSink)
{
if (nsCRT::strcmp(kLoadAsData, aCommand) == 0) {
// We need to disable script & style loading in this case.
// We leave them disabled even in EndLoad(), and let anyone
// who puts the document on display to worry about enabling.
// scripts
nsCOMPtr<nsIScriptLoader> loader;
nsresult rv = GetScriptLoader(getter_AddRefs(loader));
if (NS_FAILED(rv))
return rv;
if (loader) {
loader->SetEnabled(PR_FALSE); // Do not load/process scripts when loading as data
}
// styles
nsCOMPtr<nsICSSLoader> cssLoader;
rv = GetCSSLoader(*getter_AddRefs(cssLoader));
if (NS_FAILED(rv))
return rv;
if (cssLoader) {
cssLoader->SetEnabled(PR_FALSE); // Do not load/process styles when loading as data
}
} else if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) {
aCommand = kLoadAsData; // XBL, for example, needs scripts and styles
}
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
aChannel, aLoadGroup,
aContainer,