Bug 1299391 - fix decimal IP detection for 'did you mean this host instead' when we fix up URIs for search, r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 31 Aug 2016 11:47:44 +0100
changeset 408646 6c29ae3625b37428e5c6faef41c3c32664eb0093
parent 407818 506facea63169a29e04eb140663da1730052db64
child 530156 a12a00d348b155e64a1b2fa102de6eeb5480d970
push id28263
push usergijskruitbosch@gmail.com
push dateThu, 01 Sep 2016 12:30:51 +0000
reviewersjaws
bugs1299391
milestone51.0a1
Bug 1299391 - fix decimal IP detection for 'did you mean this host instead' when we fix up URIs for search, r?jaws MozReview-Commit-ID: JTwxbvkATm0
browser/base/content/browser.js
browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -698,17 +698,17 @@ function gKeywordURIFixup({ target: brow
   // because we need to be sure this last dot is the *only* dot, too.
   // More generally, this is used for the pref and should stay in sync with
   // the code in nsDefaultURIFixup::KeywordURIFixup .
   if (asciiHost.indexOf('.') == asciiHost.length - 1) {
     asciiHost = asciiHost.slice(0, -1);
   }
 
   // Ignore number-only things entirely (no decimal IPs for you!)
-  if (/^\d+$/.test(asciiHost))
+  if (/^\d+$/.test(fixupInfo.originalInput.trim()))
     return;
 
   let onLookupComplete = (request, record, status) => {
     let browser = weakBrowser.get();
     if (!Components.isSuccessCode(status) || !browser)
       return;
 
     let currentURI = browser.currentURI;
--- a/browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
+++ b/browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
@@ -61,24 +61,24 @@ function* runURLBarSearchTest(valueToOpe
 
 add_task(function* test_navigate_full_domain() {
   let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield* runURLBarSearchTest("www.mozilla.org", false, false);
   gBrowser.removeTab(tab);
 });
 
-add_task(function* test_navigate_valid_numbers() {
+add_task(function* test_navigate_decimal_ip() {
   let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  yield* runURLBarSearchTest("1234", true, true);
+  yield* runURLBarSearchTest("1234", true, false);
   gBrowser.removeTab(tab);
 });
 
-add_task(function* test_navigate_invalid_numbers() {
+add_task(function* test_navigate_large_number() {
   let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield* runURLBarSearchTest("123456789012345", true, false);
   gBrowser.removeTab(tab);
 });
 function get_test_function_for_localhost_with_hostname(hostName, isPrivate) {
   return function* test_navigate_single_host() {
     const pref = "browser.fixup.domainwhitelist.localhost";