Bug 427304 Cannot search with non-ascii characters (nsURLFormatter wrongly parses encoded uri) p=Kohei Yoshino<kohei.yoshino.bugs@gmail.com>, r=gavin, a1.9=beltzner

This commit is contained in:
masayuki@d-toybox.com 2008-04-23 00:42:30 -07:00
parent 3eed9719db
commit cca6b04a8c
2 changed files with 5 additions and 1 deletions

View File

@ -87,7 +87,7 @@ nsURLFormatterService.prototype = {
if (aKey in _this._defaults) // supported defaults
return _this._defaults[aKey]();
Cu.reportError("formatURL: Couldn't find value for key: " + aKey);
return '';
return aMatch;
}
return aFormat.replace(/%([A-Z]+)%/g, replacementCallback);
},

View File

@ -48,6 +48,8 @@ function run_test() {
var ulUrlRef = "http://" + locale + ".Mozilla.foo/?name=Url Formatter Test&id=urlformattertest@test.mozilla.org&version=1&platversion=2.0&abid=2007122405&pbid=2007122406&app=urlformatter test&os=XPCShell&abi=noarch-spidermonkey";
var multiUrl = "http://%VENDOR%.%VENDOR%.%NAME%.%VENDOR%.%NAME%";
var multiUrlRef = "http://Mozilla.Mozilla.Url Formatter Test.Mozilla.Url Formatter Test";
var encodedUrl = "https://%LOCALE%.%VENDOR%.foo/?q=%E3%82%BF%E3%83%96&app=%name%&ver=%PLATFORMVERSION%";
var encodedUrlRef = "https://" + locale + ".Mozilla.foo/?q=%E3%82%BF%E3%83%96&app=Url Formatter Test&ver=2.0";
var pref = "xpcshell.urlformatter.test";
var str = Cc["@mozilla.org/supports-string;1"].
@ -60,4 +62,6 @@ function run_test() {
// Keys must be uppercase
do_check_neq(formatter.formatURL(lowerUrlRaw), ulUrlRef);
do_check_eq(formatter.formatURL(multiUrl), multiUrlRef);
// Encoded strings must be kept as is (Bug 427304)
do_check_eq(formatter.formatURL(encodedUrl), encodedUrlRef);
}