1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

This addresses #1082

This commit is contained in:
gorhill 2015-03-23 18:49:28 -04:00
parent 032a63f295
commit 29269617ab

View File

@ -76,6 +76,7 @@ var nameToActionMap = {
// For performance purpose, as simple tests as possible // For performance purpose, as simple tests as possible
var reHostnameVeryCoarse = /[g-z_-]/; var reHostnameVeryCoarse = /[g-z_-]/;
var reIPv4VeryCoarse = /\.\d+$/; var reIPv4VeryCoarse = /\.\d+$/;
var reBadHostname = /[^0-9a-z_.\[\]:-]/;
// http://tools.ietf.org/html/rfc5952 // http://tools.ietf.org/html/rfc5952
// 4.3: "MUST be represented in lowercase" // 4.3: "MUST be represented in lowercase"
@ -539,6 +540,12 @@ Matrix.prototype.fromString = function(text, append) {
srcHostname = punycode.toASCII(fields[0]); srcHostname = punycode.toASCII(fields[0]);
desHostname = punycode.toASCII(fields[1]); 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]; type = fields[2];
if ( typeBitOffsets.hasOwnProperty(type) === false ) { if ( typeBitOffsets.hasOwnProperty(type) === false ) {
continue; continue;