From 541fe2dc37e7cf96ab118c05074fd0a0b64b9302 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Fri, 15 Sep 2006 09:52:06 +0000 Subject: [PATCH] Allow about: modules to just set a flag to force script execution to be allowed for particular about: URIs, instead of hardcoding checks in the security manager. Bug 341313, r=darin, sr=jst git-svn-id: svn://10.0.0.236/trunk@211811 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsAboutRedirector.cpp | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mozilla/docshell/base/nsAboutRedirector.cpp b/mozilla/docshell/base/nsAboutRedirector.cpp index 41363da8d02..31710d32a5f 100644 --- a/mozilla/docshell/base/nsAboutRedirector.cpp +++ b/mozilla/docshell/base/nsAboutRedirector.cpp @@ -51,6 +51,9 @@ struct RedirEntry { const char* id; const char* url; PRBool dropChromePrivs; // if PR_TRUE, the page will not have chrome privileges + PRBool allowScripts; // if PR_TRUE, the page will be able to run scripts + // even if script is generally disabled and it + // doesn't have chrome privileges. Use sparingly! }; /* @@ -61,16 +64,17 @@ struct RedirEntry { before adding new map entries with dropChromePrivs == PR_FALSE. */ static RedirEntry kRedirMap[] = { - { "credits", "http://www.mozilla.org/credits/", PR_TRUE }, - { "mozilla", "chrome://global/content/mozilla.xhtml", PR_TRUE }, - { "plugins", "chrome://global/content/plugins.html", PR_FALSE }, - { "config", "chrome://global/content/config.xul", PR_FALSE }, - { "logo", "chrome://global/content/logo.gif", PR_TRUE }, - { "buildconfig", "chrome://global/content/buildconfig.html", PR_TRUE }, - { "license", "chrome://global/content/license.html", PR_TRUE }, - { "licence", "chrome://global/content/license.html", PR_TRUE }, - { "about", "chrome://global/content/aboutAbout.html", PR_FALSE }, - { "neterror", "chrome://global/content/netError.xhtml", PR_TRUE } + { "credits", "http://www.mozilla.org/credits/", PR_TRUE, PR_FALSE }, + { "mozilla", "chrome://global/content/mozilla.xhtml", PR_TRUE, PR_FALSE }, + { "plugins", "chrome://global/content/plugins.html", PR_FALSE, PR_FALSE }, + { "config", "chrome://global/content/config.xul", PR_FALSE, PR_FALSE }, + { "logo", "chrome://global/content/logo.gif", PR_TRUE, PR_FALSE }, + { "buildconfig", "chrome://global/content/buildconfig.html", + PR_TRUE, PR_FALSE }, + { "license", "chrome://global/content/license.html", PR_TRUE, PR_FALSE }, + { "licence", "chrome://global/content/license.html", PR_TRUE, PR_FALSE }, + { "about", "chrome://global/content/aboutAbout.html", PR_FALSE, PR_FALSE }, + { "neterror", "chrome://global/content/netError.xhtml", PR_TRUE, PR_TRUE } }; static const int kRedirTotal = NS_ARRAY_LENGTH(kRedirMap); @@ -145,6 +149,9 @@ nsAboutRedirector::GetURIFlags(nsIURI *aURI, PRUint32 *result) { *result = kRedirMap[i].dropChromePrivs ? nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT : 0; + if (kRedirMap[i].allowScripts) { + *result |= nsIAboutModule::ALLOW_SCRIPT; + } return NS_OK; } }