Bug 1083634 - entering a trailing slash after a domain should not do a search. r=smaug r=Unfocused
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 22 Dec 2014 00:03:26 +0000
changeset 221061 ebe9fac9d095cd599a4dc5f166adeaabc118468c
parent 221060 c29ebd2b4a10c5c95a0bd3c1c3b41dd8b40c1c17
child 221062 8450d74f782e7cc021fe4c93bbe77f7d8c440434
push id28009
push userryanvm@gmail.com
push dateTue, 23 Dec 2014 18:17:16 +0000
treeherdermozilla-central@44344099d119 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, Unfocused
bugs1083634
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1083634 - entering a trailing slash after a domain should not do a search. r=smaug r=Unfocused
docshell/base/nsDefaultURIFixup.cpp
docshell/test/unit/test_nsDefaultURIFixup_info.js
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -1091,16 +1091,23 @@ nsDefaultURIFixup::KeywordURIFixup(const
     else if ((firstDotLoc == uint32_t(kNotFound) ||
               (foundDots == 1 && (firstDotLoc == 0 || firstDotLoc == aURIString.Length() - 1))) &&
               firstColonLoc == uint32_t(kNotFound) && firstQMarkLoc == uint32_t(kNotFound)) {
 
         if (isValidAsciiHost && IsDomainWhitelisted(asciiHost, firstDotLoc)) {
             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);
     }
     return rv;
 }
 
 bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
--- a/docshell/test/unit/test_nsDefaultURIFixup_info.js
+++ b/docshell/test/unit/test_nsDefaultURIFixup_info.js
@@ -371,16 +371,24 @@ let testcases = [ {
     input: "5+2",
     fixedURI: "http://5+2/",
     alternateURI: "http://www.5+2.com/",
     keywordLookup: true,
     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,
     protocolChange: true
   }, {
     input: "mozilla.com/?q=search",
     fixedURI: "http://mozilla.com/?q=search",
     alternateURI: "http://www.mozilla.com/?q=search",
     protocolChange: true
@@ -443,16 +451,42 @@ let testcases = [ {
     affectedByWhitelist: true
   }, {
     input: "??mozilla",
     fixedURI: "http:///??mozilla",
     alternateURI: "http://www..com/??mozilla",
     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")) {
   testcases.push({
     input: "C:\\some\\file.txt",
     fixedURI: "file:///C:/some/file.txt",
     protocolChange: true,
   });
@@ -462,20 +496,18 @@ if (Services.appinfo.OS.toLowerCase().st
     alternateURI: "http://www.mozilla.com/",
     protocolChange: true,
     affectedByWhitelist: true,
   });
   testcases.push({
     input: "mozilla\\",
     fixedURI: "http://mozilla/",
     alternateURI: "http://www.mozilla.com/",
-    keywordLookup: true,
     protocolChange: true,
     affectedByWhitelist: true,
-    affectedByDNSForSingleHosts: true,
   });
 } else {
   testcases.push({
     input: "/some/file.txt",
     fixedURI: "file:///some/file.txt",
     protocolChange: true,
   });
   testcases.push({