Bug 775072 - Inline autocomplete munges URLs that contain characters that would normally be escaped. r=mak

This commit is contained in:
Blair McBride 2012-08-23 00:44:19 +12:00
parent 98d8b7753d
commit cb597dd0a3
2 changed files with 25 additions and 3 deletions

View File

@ -130,6 +130,19 @@ function initTempTable(aDatabase)
* @return the modified uri.
*/
function fixupSearchText(aURIString)
{
let uri = stripPrefix(aURIString);
return gTextURIService.unEscapeURIForUI("UTF-8", uri);
}
/**
* Strip prefixes from the URI that we don't care about for searching.
*
* @param aURIString
* The text to modify.
* @return the modified uri.
*/
function stripPrefix(aURIString)
{
let uri = aURIString;
@ -146,8 +159,7 @@ function fixupSearchText(aURIString)
if (uri.indexOf("www.") == 0) {
uri = uri.slice(4);
}
return gTextURIService.unEscapeURIForUI("UTF-8", uri);
return uri;
}
/**
@ -1487,7 +1499,7 @@ urlInlineComplete.prototype = {
let value = row.getResultByIndex(0);
let url = fixupSearchText(value);
let prefix = value.slice(0, value.length - url.length);
let prefix = value.slice(0, value.length - stripPrefix(value).length);
// We must complete the URL up to the next separator (which is /, ? or #).
let separatorIndex = url.slice(this._currentSearchString.length)

View File

@ -132,3 +132,13 @@ add_autocomplete_test([
addBookmark({ url: "http://mozilla.co/" });
},
]);
add_autocomplete_test([
"Searching for URL with characters that are normally escaped",
"https://www.mozilla.org/啊-test",
{ autoFilled: "https://www.mozilla.org/啊-test", completed: "https://www.mozilla.org/啊-test" },
function () {
addVisits({ uri: NetUtil.newURI("https://www.mozilla.org/啊-test"),
transition: TRANSITION_TYPED });
},
]);