Bug 1053245 - Ignore number-only hosts in showing notification bars for keyword URI redirection. r=jaws, a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 13 Aug 2014 21:04:03 +0100
changeset 217626 e16e1167bce960323eda837a0e234492f915461a
parent 217625 79d6b9d86e46c4c9feb1ed9be5d40d4cefc8c62b
child 217627 dd47c5828c9c2dcc5523a2c665da82914af1799d
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, sledru
bugs1053245
milestone33.0a2
Bug 1053245 - Ignore number-only hosts in showing notification bars for keyword URI redirection. r=jaws, a=sledru
browser/base/content/browser.js
browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -808,16 +808,20 @@ function gKeywordURIFixup(fixupInfo, top
   // Normalize out a single trailing dot - NB: not using endsWith/lastIndexOf
   // 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))
+    return;
+
   let onLookupComplete = (request, record, status) => {
     let browser = weakBrowser.get();
     if (!Components.isSuccessCode(status) || !browser)
       return;
 
     let currentURI = browser.currentURI;
     // If we're in case (3) (see above), don't show an info bar.
     if (!currentURI.equals(previousURI) &&
--- a/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
+++ b/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js
@@ -57,16 +57,22 @@ function* runURLBarSearchTest(valueToOpe
 }
 
 add_task(function* test_navigate_full_domain() {
   let tab = gBrowser.selectedTab = gBrowser.addTab();
   yield* runURLBarSearchTest("www.mozilla.org", false, false);
   gBrowser.removeTab(tab);
 });
 
+add_task(function* test_navigate_numbers() {
+  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  yield* runURLBarSearchTest("1234", 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";
     let win = isPrivate ? yield promiseOpenAndLoadWindow({private: true}, true) : window;
     let browser = win.gBrowser;
     let tab = browser.selectedTab = browser.addTab();
 
     Services.prefs.setBoolPref(pref, false);