From 6115ede7b5a93707718aee1a63d33802228f67ee Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Thu, 14 Jul 2005 17:46:55 +0000 Subject: [PATCH] Bug 292624 - XUL error pages should not have chrome privileges, r=darin sr=dveditz a=asa --- caps/src/nsScriptSecurityManager.cpp | 3 +- docshell/base/nsDocShell.cpp | 15 +--- docshell/resources/content/jar.mn | 1 - docshell/resources/content/netError.js | 0 docshell/resources/content/netError.xhtml | 83 +++++++++++++++++-- netwerk/build/nsNetModule.cpp | 5 ++ .../about/src/nsAboutProtocolHandler.cpp | 35 ++++---- .../about/src/nsAboutProtocolHandler.h | 4 + .../protocol/about/src/nsAboutRedirector.cpp | 8 +- 9 files changed, 111 insertions(+), 43 deletions(-) delete mode 100644 docshell/resources/content/netError.js diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index b10888c4d60..bb770d2f4a5 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -1566,7 +1566,8 @@ nsScriptSecurityManager::CanExecuteScripts(JSContext* cx, { nsCAutoString spec; principalURI->GetSpec(spec); - if (spec.EqualsLiteral("about:")) + if (spec.EqualsLiteral("about:") || + StringBeginsWith(spec, NS_LITERAL_CSTRING("about:neterror?"))) { *result = PR_TRUE; return NS_OK; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 37c262cd102..5701d4be2bf 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3051,21 +3051,8 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, char *escapedError = nsEscape(NS_ConvertUTF16toUTF8(aErrorType).get(), url_Path); char *escapedDescription = nsEscape(NS_ConvertUTF16toUTF8(aDescription).get(), url_Path); - nsXPIDLCString errorPageUrl; + nsCString errorPageUrl("about:neterror?e="); - nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefBranch) - { - // Note that we don't expose this pref, because we don't want users fiddling with it. - prefBranch->GetCharPref("browser.xul.error_pages.location", getter_Copies(errorPageUrl)); - } - - if (errorPageUrl.IsEmpty()) - { - errorPageUrl.AssignLiteral("chrome://global/content/netError.xhtml"); - } - - errorPageUrl.AppendLiteral("?e="); errorPageUrl.AppendASCII(escapedError); errorPageUrl.AppendLiteral("&u="); errorPageUrl.AppendASCII(escapedUrl); diff --git a/docshell/resources/content/jar.mn b/docshell/resources/content/jar.mn index 58fed605d4e..f1641c86010 100644 --- a/docshell/resources/content/jar.mn +++ b/docshell/resources/content/jar.mn @@ -1,3 +1,2 @@ toolkit.jar: content/global/netError.xhtml - content/global/netError.js diff --git a/docshell/resources/content/netError.js b/docshell/resources/content/netError.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/docshell/resources/content/netError.xhtml b/docshell/resources/content/netError.xhtml index 2bc4317ad7d..171a4fde773 100644 --- a/docshell/resources/content/netError.xhtml +++ b/docshell/resources/content/netError.xhtml @@ -51,7 +51,6 @@ &loadError.label; -