mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 17:57:58 +01:00
Cleanup more crufty, stolen Gecko code. Aren't these people supposed to be professionals?
--HG-- extra : rebase_source : 288a8a5f8479dda0c16c1a66132682e71f9a8eba
This commit is contained in:
@@ -475,7 +475,7 @@ function Bookmarks() //{{{
|
||||
let query = item.url.substring(begin.length, rest);
|
||||
if (item.url.substr(rest) == end && query.indexOf("&") == -1)
|
||||
{
|
||||
item.url = decodeURIComponent(query);
|
||||
item.url = decodeURIComponent(query.replace(/#.*/, ""));
|
||||
return item;
|
||||
}
|
||||
}).filter(util.identity);
|
||||
|
||||
@@ -2128,43 +2128,34 @@ function StatusLine() //{{{
|
||||
*/
|
||||
updateUrl: function updateUrl(url)
|
||||
{
|
||||
// ripped from Firefox
|
||||
if (!window.losslessDecodeURI)
|
||||
window.losslessDecodeURI = function (aURI, aPostDataRef) {
|
||||
var value = aURI.spec;
|
||||
// Try to decode as UTF-8 if there's no encoding sequence that we would break.
|
||||
if (!/%25(?:3B|2F|3F|3A|40|26|3D|2B|24|2C|23)/i.test(value))
|
||||
try
|
||||
{
|
||||
value = decodeURI(value)
|
||||
// ripped from Firefox; modified
|
||||
function losslessDecodeURI(url) {
|
||||
// 1. decodeURI decodes %25 to %, which creates unintended
|
||||
// encoding sequences. Re-encode it, unless it's part of
|
||||
// a sequence that survived decodeURI, i.e. one for:
|
||||
// ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '#'
|
||||
// (RFC 3987 section 3.2)
|
||||
url = url.split("%25").map(decodeURI).join("%25");
|
||||
// 2. Re-encode whitespace so that it doesn't get eaten away
|
||||
// by the location bar (bug 410726).
|
||||
.replace(/%(?!3B|2F|3F|3A|40|26|3D|2B|24|2C|23)|[\r\n\t]/ig,
|
||||
encodeURIComponent);
|
||||
}
|
||||
catch (e) {}
|
||||
url = url.replace(/[\r\n\t]/g, encodeURIComponent);
|
||||
|
||||
// Encode invisible characters (soft hyphen, zero-width space, BOM,
|
||||
// line and paragraph separator, word joiner, invisible times,
|
||||
// invisible separator, object replacement character) (bug 452979)
|
||||
value = value.replace(/[\v\x0c\x1c\x1d\x1e\x1f\u00ad\u200b\ufeff\u2028\u2029\u2060\u2062\u2063\ufffc]/g,
|
||||
url = url.replace(/[\v\x0c\x1c\x1d\x1e\x1f\u00ad\u200b\ufeff\u2028\u2029\u2060\u2062\u2063\ufffc]/g,
|
||||
encodeURIComponent);
|
||||
|
||||
// Encode bidirectional formatting characters.
|
||||
// (RFC 3987 sections 3.2 and 4.1 paragraph 6)
|
||||
value = value.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
|
||||
url = url.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
|
||||
encodeURIComponent);
|
||||
return value;
|
||||
return url;
|
||||
};
|
||||
|
||||
if (url == null)
|
||||
// TODO: this probably needs a more general solution.
|
||||
url = losslessDecodeURI(util.newURI(buffer.URL));
|
||||
url = losslessDecodeURI(buffer.URL);
|
||||
|
||||
// make it even more Vim-like
|
||||
if (url == "about:blank")
|
||||
|
||||
Reference in New Issue
Block a user