From 4cb4e33c8f160a36556f64492b8974c47a365b7d Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Thu, 27 Mar 2003 20:17:20 +0000 Subject: [PATCH] Fix for bug 161546. r=alecf, sr=heikki. JS and data urls can no longer be loaded from the history window or sidebar. An alert with an error will pop up if a user tries to load such urls from the history window/sidebar. a=asa. git-svn-id: svn://10.0.0.236/trunk@140404 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/history/resources/history.js | 17 ++++++++++++++++- .../resources/locale/en-US/history.properties | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mozilla/xpfe/components/history/resources/history.js b/mozilla/xpfe/components/history/resources/history.js index b832a1da48b..49cfc58d38c 100644 --- a/mozilla/xpfe/components/history/resources/history.js +++ b/mozilla/xpfe/components/history/resources/history.js @@ -278,7 +278,22 @@ function OpenURL(aInNewWindow) var currentIndex = gHistoryTree.currentIndex; var builder = gHistoryTree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder); var url = builder.getResourceAtIndex(currentIndex).Value; - + var uri = Components.classes["@mozilla.org/network/standard-url;1"]. + createInstance(Components.interfaces.nsIURI); + uri.spec = url; + if (uri.schemeIs("javascript") || uri.schemeIs("data")) { + var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"] + .getService(Components.interfaces.nsIStringBundleService); + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + var historyBundle = strBundleService.createBundle("chrome://communicator/locale/history/history.properties"); + var brandBundle = strBundleService.createBundle("chrome://global/locale/brand.properties"); + var brandStr = brandBundle.GetStringFromName("brandShortName"); + var errorStr = historyBundle.GetStringFromName("load-js-data-url-error"); + promptService.alert(window, brandStr, errorStr); + return false; + } + if (aInNewWindow) { var count = gHistoryTree.treeBoxObject.view.selection.count; if (count == 1) { diff --git a/mozilla/xpfe/components/history/resources/locale/en-US/history.properties b/mozilla/xpfe/components/history/resources/locale/en-US/history.properties index 13c7104a1b7..94d90217af9 100644 --- a/mozilla/xpfe/components/history/resources/locale/en-US/history.properties +++ b/mozilla/xpfe/components/history/resources/locale/en-US/history.properties @@ -17,3 +17,5 @@ collapseLabel=Collapse expandLabel=Expand collapseAccesskey=C expandAccesskey=x + +load-js-data-url-error=For security reasons, javascript or data urls cannot be loaded from the history window or sidebar.