Bug 1304826 - Expanded the regexp so that large hex numbers are not recognized as IP address. r=Gijs

MozReview-Commit-ID: IwQMyYj6D5Z

--HG--
extra : rebase_source : c8c5a09e91c013848459874a9ab7cdc9130df17d
This commit is contained in:
Saad Siddiqui 2016-10-04 13:44:17 +05:30
parent 7a8fff8a42
commit 60b9984753
2 changed files with 24 additions and 1 deletions

View File

@ -709,7 +709,7 @@ function gKeywordURIFixup({ target: browser, data: fixupInfo }) {
// making it the same as 7f000001, which is 127.0.0.1 aka localhost.
// While 2130706433 would get normalized by network, 1097347366913
// does not, and we have to deal with both cases here:
if (isIPv4Address(asciiHost) || /^\d+$/.test(asciiHost))
if (isIPv4Address(asciiHost) || /^(?:\d+|0x[a-f0-9]+)$/i.test(asciiHost))
return;
let onLookupComplete = (request, record, status) => {

View File

@ -103,6 +103,29 @@ add_task(function* test_navigate_large_number() {
});
gBrowser.removeTab(tab);
});
add_task(function* test_navigate_small_hex_number() {
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
yield* runURLBarSearchTest({
valueToOpen: "0x1f00ffff",
expectSearch: true,
expectNotification: false
});
gBrowser.removeTab(tab);
});
add_task(function* test_navigate_large_hex_number() {
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
yield* runURLBarSearchTest({
valueToOpen: "0x7f0000017f000001",
expectSearch: true,
expectNotification: 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";