From 5576a5f5e617ebd70a63994a8446e6725237f24c Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 2 Feb 2011 09:26:56 -0500 Subject: [PATCH] Only explicitly demangle subscript URIs rather than doing it automatically in newURI. Closes issue #185. --- common/modules/base.jsm | 2 +- common/modules/bookmarkcache.jsm | 2 +- common/modules/io.jsm | 4 ++-- common/modules/overlay.jsm | 2 +- common/modules/template.jsm | 2 +- common/modules/util.jsm | 13 +++++++++---- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/common/modules/base.jsm b/common/modules/base.jsm index badf93f8..c456a9d9 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -281,7 +281,7 @@ function deprecated(alternative, fn) { let obj = this.className ? this.className + "#" : this.constructor.className ? this.constructor.className + "#" : ""; - let filename = (frame.filename || "unknown").replace(/.* -> /, ""); + let filename = util.fixURI(frame.filename || "unknown"); if (!set.add(deprecatedMethod.seen, filename)) util.dactyl(fn).warn( util.urlPath(filename) + ":" + frame.lineNumber + ": " + diff --git a/common/modules/bookmarkcache.jsm b/common/modules/bookmarkcache.jsm index ebea960b..264f8e61 100644 --- a/common/modules/bookmarkcache.jsm +++ b/common/modules/bookmarkcache.jsm @@ -183,7 +183,7 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), { let bookmark = this.bookmarks[itemId]; if (bookmark) { if (property == "tags") - value = services.tagging.getTagsForURI(util.newURI(bookmark.url), {}); + value = services.tagging.getTagsForURI(bookmark.uri, {}); if (property in bookmark) { bookmark[bookmark.members[property]] = value; storage.fireEvent(name, "change", { __proto__: bookmark, changed: property }); diff --git a/common/modules/io.jsm b/common/modules/io.jsm index e8fb057f..4c719c4c 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -173,7 +173,7 @@ var IO = Module("io", { catch (e) { if (e.fileName) try { - e.fileName = e.fileName.replace(/^(chrome|resource):.*? -> /, ""); + e.fileName = util.fixURI(e.fileName); if (e.fileName == uri.spec) e.fileName = filename; e.echoerr = <>{e.fileName}:{e.lineNumber}: {e}; @@ -328,7 +328,7 @@ var IO = Module("io", { */ isJarURL: function isJarURL(url) { try { - let uri = util.newURI(url); + let uri = util.newURI(util.fixURI(url)); let channel = services.io.newChannelFromURI(uri); channel.cancel(Cr.NS_BINDING_ABORTED); if (channel instanceof Ci.nsIJARChannel) diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index c456b8a8..aef42de6 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -243,7 +243,7 @@ var Overlay = Module("Overlay", { defineModule.loadLog.push("Load" + (isString(prereq) ? " " + prereq + " dependency: " : ": ") + module.className); if (frame && frame.filename) - defineModule.loadLog.push(" from: " + frame.filename.replace(/.* -> /, "") + ":" + frame.lineNumber); + defineModule.loadLog.push(" from: " + util.fixURI(frame.filename) + ":" + frame.lineNumber); delete modules[module.className]; modules[module.className] = defineModule.time(module.className, "init", module); diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 8cec311f..cd85bb54 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -374,7 +374,7 @@ var Template = Module("Template", { }, sourceLink: function (frame) { - let url = (frame.filename || "unknown").replace(/.* -> /, ""); + let url = util.fixURI(frame.filename || "unknown"); let path = util.urlPath(url); XML.ignoreWhitespace = false; XML.prettyPrinting = false; diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 3fc01164..6d16de46 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -526,7 +526,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), let match, re = /([^]*?)@([^@\n]*)(?:\n|$)/g; while (match = re.exec(stack)) lines.push(match[1].replace(/\n/g, "\\n").substr(0, 80) + "@" + - match[2].replace(/.* -> /, "")); + util.fixURI(match[2])); return lines; }, @@ -712,7 +712,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), getFile: function getFile(uri) { try { if (isString(uri)) - uri = util.newURI(uri); + uri = util.newURI(util.fixURI(uri)); if (uri instanceof Ci.nsIFileURL) return File(uri.QueryInterface(Ci.nsIFileURL).file); @@ -885,7 +885,13 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * @returns {nsIURI} */ // FIXME: createURI needed too? - newURI: function (uri, charset, base) services.io.newURI(String.replace(uri, /.* -> /, ""), charset, base), + newURI: function (uri, charset, base) services.io.newURI(uri, charset, base), + + /** + * Removes leading garbage prepended to URIs by the subscript + * loader. + */ + fixURI: function fixURI(url) String.replace(url, /.* -> /, ""), /** * Pretty print a JavaScript object. Use HTML markup to color certain items @@ -1579,7 +1585,6 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), }, urlPath: function urlPath(url) { - url = (url || "unknown").replace(/.* -> /, ""); try { return util.getFile(url).path; }