diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index ddb9940f..f076bee8 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -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); diff --git a/common/content/ui.js b/common/content/ui.js index 6749d0bf..9902f6fe 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -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) - // 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) - // 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) {} + // 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). + 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, - 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) + 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, - encodeURIComponent); - return value; - }; + // Encode bidirectional formatting characters. + // (RFC 3987 sections 3.2 and 4.1 paragraph 6) + url = url.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g, + encodeURIComponent); + 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")