From 29269617abe87778ee4a0d14dd03947364ead476 Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 23 Mar 2015 18:49:28 -0400 Subject: [PATCH] This addresses #1082 --- src/js/dynamic-net-filtering.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js index 7b6666745..d22e714db 100644 --- a/src/js/dynamic-net-filtering.js +++ b/src/js/dynamic-net-filtering.js @@ -76,6 +76,7 @@ var nameToActionMap = { // For performance purpose, as simple tests as possible var reHostnameVeryCoarse = /[g-z_-]/; var reIPv4VeryCoarse = /\.\d+$/; +var reBadHostname = /[^0-9a-z_.\[\]:-]/; // http://tools.ietf.org/html/rfc5952 // 4.3: "MUST be represented in lowercase" @@ -539,6 +540,12 @@ Matrix.prototype.fromString = function(text, append) { srcHostname = punycode.toASCII(fields[0]); desHostname = punycode.toASCII(fields[1]); + // https://github.com/gorhill/uBlock/issues/1082 + // Discard rules with invalid hostnames + if ( reBadHostname.test(srcHostname) || reBadHostname.test(desHostname) ) { + continue; + } + type = fields[2]; if ( typeBitOffsets.hasOwnProperty(type) === false ) { continue;