mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 17:47:59 +01:00
Move statusline.losslessDecodeURI to util.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -188,34 +188,8 @@ var StatusLine = Module("statusline", {
|
||||
this.updateZoomLevel();
|
||||
},
|
||||
|
||||
// ripped from Firefox; modified
|
||||
unsafeURI: util.regexp(String.replace(<![CDATA[
|
||||
[
|
||||
\s
|
||||
// Invisible characters (bug 452979)
|
||||
U001C U001D U001E U001F // file/group/record/unit separator
|
||||
U00AD // Soft hyphen
|
||||
UFEFF // BOM
|
||||
U2060 // Word joiner
|
||||
U2062 U2063 // Invisible times/separator
|
||||
U200B UFFFC // Zero-width space/no-break space
|
||||
|
||||
// Bidi formatting characters. (RFC 3987 sections 3.2 and 4.1 paragraph 6)
|
||||
U200E U200F U202A U202B U202C U202D U202E
|
||||
]
|
||||
]]>, /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") {
|
||||
|
||||
@@ -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(<![CDATA[
|
||||
[
|
||||
\s
|
||||
// Invisible characters (bug 452979)
|
||||
U001C U001D U001E U001F // file/group/record/unit separator
|
||||
U00AD // Soft hyphen
|
||||
UFEFF // BOM
|
||||
U2060 // Word joiner
|
||||
U2062 U2063 // Invisible times/separator
|
||||
U200B UFFFC // Zero-width space/no-break space
|
||||
|
||||
// Bidi formatting characters. (RFC 3987 sections 3.2 and 4.1 paragraph 6)
|
||||
U200E U200F U202A U202B U202C U202D U202E
|
||||
]
|
||||
]]>, /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
|
||||
|
||||
Reference in New Issue
Block a user