diff --git a/common/content/browser.js b/common/content/browser.js index e9d6e1bf..5a6ba5ef 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -212,9 +212,9 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), ["o"], "Open one or more URLs", function () { CommandExMode().open("open "); }); - function decode(uri) statusline.losslessDecodeURI(uri) - .replace(/%20(?!(?:%20)*$)/g, " ") - .replace(RegExp(options["urlseparator"], "g"), encodeURIComponent); + function decode(uri) util.losslessDecodeURI(uri) + .replace(/%20(?!(?:%20)*$)/g, " ") + .replace(RegExp(options["urlseparator"], "g"), encodeURIComponent); mappings.add([modes.NORMAL], ["O"], "Open one or more URLs, based on current location", diff --git a/common/content/statusline.js b/common/content/statusline.js index 6a9137c6..ebeda101 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -188,34 +188,8 @@ var StatusLine = Module("statusline", { this.updateZoomLevel(); }, - // ripped from Firefox; modified - unsafeURI: util.regexp(String.replace(, /U/g, "\\u"), - "gx"), - losslessDecodeURI: function losslessDecodeURI(url) { - return url.split("%25").map(function (url) { - // Non-UTF-8 compliant URLs cause "malformed URI sequence" errors. - try { - return decodeURI(url).replace(this.unsafeURI, encodeURIComponent); - } - catch (e) { - return url; - } - }, this).join("%25"); - }, + unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() util.unsafeURI }), + losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() util.losslessDecodeURI.apply(util, arguments)), /** * Update the URL displayed in the status line. Also displays status @@ -245,7 +219,7 @@ var StatusLine = Module("statusline", { if (modules.quickmarks) modified += quickmarks.find(uri.spec.replace(/#.*/, "")).join(""); - url = this.losslessDecodeURI(uri.spec); + url = util.losslessDecodeURI(uri.spec); } if (url == "about:blank") { diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 3d646e05..ee1b2bad 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -1028,6 +1028,35 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), } }, + // ripped from Firefox; modified + unsafeURI: Class.memoize(function () util.regexp(String.replace(, /U/g, "\\u"), + "gx")), + losslessDecodeURI: function losslessDecodeURI(url) { + return url.split("%25").map(function (url) { + // Non-UTF-8 compliant URLs cause "malformed URI sequence" errors. + try { + return decodeURI(url).replace(this.unsafeURI, encodeURIComponent); + } + catch (e) { + return url; + } + }, this).join("%25"); + }, + /** * Returns an XPath union expression constructed from the specified node * tests. An expression is built with node tests for both the null and