mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 00:37:58 +01:00
Move statusline.losslessDecodeURI to util.
This commit is contained in:
@@ -212,7 +212,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
["o"], "Open one or more URLs",
|
["o"], "Open one or more URLs",
|
||||||
function () { CommandExMode().open("open "); });
|
function () { CommandExMode().open("open "); });
|
||||||
|
|
||||||
function decode(uri) statusline.losslessDecodeURI(uri)
|
function decode(uri) util.losslessDecodeURI(uri)
|
||||||
.replace(/%20(?!(?:%20)*$)/g, " ")
|
.replace(/%20(?!(?:%20)*$)/g, " ")
|
||||||
.replace(RegExp(options["urlseparator"], "g"), encodeURIComponent);
|
.replace(RegExp(options["urlseparator"], "g"), encodeURIComponent);
|
||||||
|
|
||||||
|
|||||||
@@ -188,34 +188,8 @@ var StatusLine = Module("statusline", {
|
|||||||
this.updateZoomLevel();
|
this.updateZoomLevel();
|
||||||
},
|
},
|
||||||
|
|
||||||
// ripped from Firefox; modified
|
unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() util.unsafeURI }),
|
||||||
unsafeURI: util.regexp(String.replace(<![CDATA[
|
losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() util.losslessDecodeURI.apply(util, arguments)),
|
||||||
[
|
|
||||||
\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");
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the URL displayed in the status line. Also displays status
|
* Update the URL displayed in the status line. Also displays status
|
||||||
@@ -245,7 +219,7 @@ var StatusLine = Module("statusline", {
|
|||||||
if (modules.quickmarks)
|
if (modules.quickmarks)
|
||||||
modified += quickmarks.find(uri.spec.replace(/#.*/, "")).join("");
|
modified += quickmarks.find(uri.spec.replace(/#.*/, "")).join("");
|
||||||
|
|
||||||
url = this.losslessDecodeURI(uri.spec);
|
url = util.losslessDecodeURI(uri.spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url == "about:blank") {
|
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
|
* Returns an XPath union expression constructed from the specified node
|
||||||
* tests. An expression is built with node tests for both the null and
|
* tests. An expression is built with node tests for both the null and
|
||||||
|
|||||||
Reference in New Issue
Block a user