зеркало из https://github.com/mozilla/gecko-dev.git
Bug 359809: properly escape keyword searches when alternative character sets are specified, r=gavin
This commit is contained in:
Родитель
26fe71a427
Коммит
e1da3047cb
|
@ -2285,9 +2285,15 @@ function getShortcutOrURI(aURL, aPostDataRef) {
|
|||
} catch (e) {}
|
||||
}
|
||||
|
||||
// encodeURIComponent produces UTF-8, and cannot be used for other charsets.
|
||||
// escape() works in those cases, but it doesn't uri-encode +, @, and /.
|
||||
// Therefore we need to manually replace these ASCII characters by their
|
||||
// encodeURIComponent result, to match the behavior of nsEscape() with
|
||||
// url_XPAlphas
|
||||
var encodedParam = "";
|
||||
if (charset)
|
||||
encodedParam = escape(convertFromUnicode(charset, param));
|
||||
if (charset && charset != "UTF-8")
|
||||
encodedParam = escape(convertFromUnicode(charset, param)).
|
||||
replace(/[+@\/]+/g, encodeURIComponent);
|
||||
else // Default charset is UTF-8
|
||||
encodedParam = encodeURIComponent(param);
|
||||
|
||||
|
|
|
@ -74,6 +74,14 @@ var testData = [
|
|||
// Explicitly-defined ISO-8859-1
|
||||
[new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "foé"),
|
||||
new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)],
|
||||
|
||||
// Bug 359809: Test escaping +, /, and @
|
||||
// UTF-8 default
|
||||
[new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "+/@"),
|
||||
new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)],
|
||||
// Explicitly-defined ISO-8859-1
|
||||
[new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "+/@"),
|
||||
new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)],
|
||||
];
|
||||
|
||||
function test() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче