From 9fba7969d07720dd9a3cf93272fd0bad2e19b1ba Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Mon, 22 Dec 2014 00:03:26 +0000 Subject: [PATCH] Bug 1083634 - entering a trailing slash after a domain should not do a search. r=smaug r=Unfocused --- docshell/base/nsDefaultURIFixup.cpp | 7 ++++ .../test/unit/test_nsDefaultURIFixup_info.js | 36 +++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 378a1d41e56b..170b2ccbff1a 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -1096,6 +1096,13 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString, return NS_OK; } + // ... unless there are no dots, and a slash, and alpha characters, and this is a valid host: + if (firstDotLoc == uint32_t(kNotFound) && lastSlashLoc != uint32_t(kNotFound) && + hasAsciiAlpha && isValidAsciiHost) { + return NS_OK; + } + + // If we get here, we don't have a valid URI, or we did but the // host is not whitelisted, so we do a keyword search *anyway*: rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData); diff --git a/docshell/test/unit/test_nsDefaultURIFixup_info.js b/docshell/test/unit/test_nsDefaultURIFixup_info.js index 373a0f1c23ec..b178ea95653a 100644 --- a/docshell/test/unit/test_nsDefaultURIFixup_info.js +++ b/docshell/test/unit/test_nsDefaultURIFixup_info.js @@ -375,6 +375,14 @@ let testcases = [ { protocolChange: true, affectedByWhitelist: true, affectedByDNSForSingleHosts: true, + }, { + input: "5/2", + fixedURI: "http://5/2", + alternateURI: "http://www.5.com/2", + keywordLookup: true, + protocolChange: true, + affectedByWhitelist: true, + affectedByDNSForSingleHosts: true, }, { input: "moz ?.::%27", keywordLookup: true, @@ -448,6 +456,32 @@ let testcases = [ { keywordLookup: true, protocolChange: true, affectedByWhitelist: true + }, { + input: "mozilla/", + fixedURI: "http://mozilla/", + alternateURI: "http://www.mozilla.com/", + protocolChange: true, + affectedByWhitelist: true, + }, { + input: "mozilla", + fixedURI: "http://mozilla/", + alternateURI: "http://www.mozilla.com/", + protocolChange: true, + keywordLookup: true, + affectedByWhitelist: true, + affectedByDNSForSingleHosts: true, + }, { + input: "mozilla5/2", + fixedURI: "http://mozilla5/2", + alternateURI: "http://www.mozilla5.com/2", + protocolChange: true, + affectedByWhitelist: true, + }, { + input: "mozilla/foo", + fixedURI: "http://mozilla/foo", + alternateURI: "http://www.mozilla.com/foo", + protocolChange: true, + affectedByWhitelist: true, }]; if (Services.appinfo.OS.toLowerCase().startsWith("win")) { @@ -467,10 +501,8 @@ if (Services.appinfo.OS.toLowerCase().startsWith("win")) { input: "mozilla\\", fixedURI: "http://mozilla/", alternateURI: "http://www.mozilla.com/", - keywordLookup: true, protocolChange: true, affectedByWhitelist: true, - affectedByDNSForSingleHosts: true, }); } else { testcases.push({