Bug 1318070 - Make sure multi-word queries are rejected when keyword.enabled is false
MozReview-Commit-ID: 6kMU2oTy456
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -1564,16 +1564,30 @@ Search.prototype = {
*_matchUnknownUrl() {
let flags = Ci.nsIURIFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS |
Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
let fixupInfo = null;
try {
fixupInfo = Services.uriFixup.getFixupURIInfo(this._originalSearchString,
flags);
} catch (e) {
+ if (e.result == Cr.NS_ERROR_MALFORMED_URI && !Prefs.keywordEnabled) {
+ let value = PlacesUtils.mozActionURI("visiturl", {
+ url: this._originalSearchString,
+ input: this._originalSearchString,
+ });
+ this._addMatch({
+ value,
+ comment: this._originalSearchString,
+ style: "action visiturl",
+ frecency: 0,
+ });
+
+ return true;
+ }
return false;
}
// If the URI cannot be fixed or the preferred URI would do a keyword search,
// that basically means this isn't useful to us. Note that
// fixupInfo.keywordAsSent will never be true if the keyword.enabled pref
// is false or there are no engines, so in that case we will always return
// a "visit".
--- a/toolkit/components/places/tests/unifiedcomplete/test_visit_url.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_visit_url.js
@@ -136,16 +136,22 @@ add_task(function*() {
Services.prefs.clearUserPref("keyword.enabled");
});
do_print("visit url, keyword.enabled = false");
yield check_autocomplete({
search: "bacon",
searchParam: "enable-actions",
matches: [ makeVisitMatch("bacon", "http://bacon/", { heuristic: true }) ]
});
+ do_print("visit two word query, keyword.enabled = false");
+ yield check_autocomplete({
+ search: "bacon lovers",
+ searchParam: "enable-actions",
+ matches: [ makeVisitMatch("bacon lovers", "bacon lovers", { heuristic: true }) ]
+ });
Services.prefs.setBoolPref("keyword.enabled", keywordEnabled);
do_print("visit url, scheme+host");
yield check_autocomplete({
search: "http://example",
searchParam: "enable-actions",
matches: [ makeVisitMatch("http://example", "http://example/", { heuristic: true }) ]
});