1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 21:37: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:
Kris Maglione
2009-10-21 04:42:04 -04:00
parent 382cbe6691
commit fa9b118aad
2 changed files with 24 additions and 33 deletions

View File

@@ -475,7 +475,7 @@ function Bookmarks() //{{{
let query = item.url.substring(begin.length, rest); let query = item.url.substring(begin.length, rest);
if (item.url.substr(rest) == end && query.indexOf("&") == -1) if (item.url.substr(rest) == end && query.indexOf("&") == -1)
{ {
item.url = decodeURIComponent(query); item.url = decodeURIComponent(query.replace(/#.*/, ""));
return item; return item;
} }
}).filter(util.identity); }).filter(util.identity);

View File

@@ -2128,43 +2128,34 @@ function StatusLine() //{{{
*/ */
updateUrl: function updateUrl(url) updateUrl: function updateUrl(url)
{ {
// ripped from Firefox // ripped from Firefox; modified
if (!window.losslessDecodeURI) function losslessDecodeURI(url) {
window.losslessDecodeURI = function (aURI, aPostDataRef) { // 1. decodeURI decodes %25 to %, which creates unintended
var value = aURI.spec; // encoding sequences. Re-encode it, unless it's part of
// Try to decode as UTF-8 if there's no encoding sequence that we would break. // a sequence that survived decodeURI, i.e. one for:
if (!/%25(?:3B|2F|3F|3A|40|26|3D|2B|24|2C|23)/i.test(value)) // ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '#'
try // (RFC 3987 section 3.2)
{ url = url.split("%25").map(decodeURI).join("%25");
value = decodeURI(value) // 2. Re-encode whitespace so that it doesn't get eaten away
// 1. decodeURI decodes %25 to %, which creates unintended // by the location bar (bug 410726).
// encoding sequences. Re-encode it, unless it's part of url = url.replace(/[\r\n\t]/g, encodeURIComponent);
// a sequence that survived decodeURI, i.e. one for:
// ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '#'
// (RFC 3987 section 3.2)
// 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) {}
// Encode invisible characters (soft hyphen, zero-width space, BOM, // Encode invisible characters (soft hyphen, zero-width space, BOM,
// line and paragraph separator, word joiner, invisible times, // line and paragraph separator, word joiner, invisible times,
// invisible separator, object replacement character) (bug 452979) // 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); encodeURIComponent);
// Encode bidirectional formatting characters. // Encode bidirectional formatting characters.
// (RFC 3987 sections 3.2 and 4.1 paragraph 6) // (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); encodeURIComponent);
return value; return url;
}; };
if (url == null) if (url == null)
// TODO: this probably needs a more general solution. // TODO: this probably needs a more general solution.
url = losslessDecodeURI(util.newURI(buffer.URL)); url = losslessDecodeURI(buffer.URL);
// make it even more Vim-like // make it even more Vim-like
if (url == "about:blank") if (url == "about:blank")