From 4851bc4f34cc2a823e25939e392c52fb836f90dc Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 1 Sep 2016 15:54:01 -0400 Subject: [PATCH] fix #1955: discard cosmetic filters with pseudo-classes --- src/js/cosmetic-filtering.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 6b85a12b8..dad78ecb2 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -330,7 +330,7 @@ FilterParser.prototype.parse = function(raw) { } // Extract the selector. - this.suffix = raw.slice(rpos + 1); + this.suffix = raw.slice(rpos + 1).trim(); if ( this.suffix.length === 0 ) { this.cosmetic = false; return this; @@ -791,10 +791,12 @@ FilterContainer.prototype.isValidSelector = (function() { var reStyleSelector = /^(.+?):style\((.+?)\)$/; var reStyleBad = /url\([^)]+\)/; - // Keep in mind: https://github.com/gorhill/uBlock/issues/693 + // Keep in mind: + // https://github.com/gorhill/uBlock/issues/693 + // https://github.com/gorhill/uBlock/issues/1955 var isValidCSSSelector = function(s) { try { - div[matchesProp](s + ',\n#foo'); + div[matchesProp](s + ', ' + s + ':not(#foo)'); } catch (ex) { return false; }