From 48c278d59e20be467e79e360cad2354d69d7e3b5 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Wed, 13 Aug 2014 21:04:03 +0100 Subject: [PATCH] Bug 1053245 - ignore number-only hosts in showing notification bars for keyword URI redirection, r=jaws --HG-- extra : rebase_source : bd1932037f7b2db212db5943a12ae7d377b49bbe --- browser/base/content/browser.js | 4 ++++ .../general/browser_urlbarSearchSingleWordNotification.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 6ee333af7cd..363b3bb45c7 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -806,6 +806,10 @@ function gKeywordURIFixup(fixupInfo, topic, data) { 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) diff --git a/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js b/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js index 2e636c52cdd..73414274085 100644 --- a/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js +++ b/browser/base/content/test/general/browser_urlbarSearchSingleWordNotification.js @@ -62,6 +62,12 @@ add_task(function* test_navigate_full_domain() { 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";