@@ -67,7 +67,7 @@ var typeNameToTypeValue = {
6767 'other' : 10 << 4 ,
6868 'popunder' : 11 << 4 ,
6969 'main_frame' : 12 << 4 ,
70- 'cosmetic-filtering ' : 13 << 4 ,
70+ 'elemhide ' : 13 << 4 ,
7171 'inline-script' : 14 << 4 ,
7272 'popup' : 15 << 4
7373} ;
@@ -86,7 +86,7 @@ var typeValueToTypeName = {
8686 10 : 'other' ,
8787 11 : 'popunder' ,
8888 12 : 'document' ,
89- 13 : 'cosmetic-filtering ' ,
89+ 13 : 'elemhide ' ,
9090 14 : 'inline-script' ,
9191 15 : 'popup'
9292} ;
@@ -1316,7 +1316,7 @@ FilterParser.prototype.toNormalizedType = {
13161316 'other' : 'other' ,
13171317 'popunder' : 'popunder' ,
13181318 'document' : 'main_frame' ,
1319- 'elemhide' : 'cosmetic-filtering ' ,
1319+ 'elemhide' : 'elemhide ' ,
13201320 'inline-script' : 'inline-script' ,
13211321 'popup' : 'popup'
13221322} ;
@@ -1359,11 +1359,13 @@ FilterParser.prototype.parseOptType = function(raw, not) {
13591359 }
13601360
13611361 // Negated type: set all valid network request type bits to 1
1362- if ( this . types === 0 ) {
1363- this . types = allNetRequestTypesBitmap ;
1362+ if (
1363+ ( typeBit & allNetRequestTypesBitmap ) !== 0 &&
1364+ ( this . types & allNetRequestTypesBitmap ) === 0
1365+ ) {
1366+ this . types |= allNetRequestTypesBitmap ;
13641367 }
1365-
1366- this . types &= ~ typeBit & allNetRequestTypesBitmap ;
1368+ this . types &= ~ typeBit ;
13671369} ;
13681370
13691371/******************************************************************************/
@@ -1401,7 +1403,6 @@ FilterParser.prototype.parseOptions = function(s) {
14011403 if ( opt === 'elemhide' || opt === 'generichide' ) {
14021404 if ( this . action === AllowAction ) {
14031405 this . parseOptType ( 'elemhide' , false ) ;
1404- this . action = BlockAction ;
14051406 continue ;
14061407 }
14071408 this . unsupported = true ;
@@ -2321,6 +2322,21 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r
23212322 var categories = this . categories ;
23222323 var key , bucket ;
23232324
2325+ // https://github.com/gorhill/uBlock/issues/1477
2326+ // Special case: blocking elemhide filter ALWAYS exists, it is implicit --
2327+ // thus we always and only check for exception filters.
2328+ if ( requestType === 'elemhide' ) {
2329+ key = AllowAnyParty | type ;
2330+ if (
2331+ ( bucket = categories [ toHex ( key ) ] ) &&
2332+ this . matchTokens ( bucket , url )
2333+ ) {
2334+ this . keyRegister = key ;
2335+ return false ;
2336+ }
2337+ return undefined ;
2338+ }
2339+
23242340 // https://github.com/chrisaljoudi/uBlock/issues/139
23252341 // Test against important block filters
23262342 key = BlockAnyParty | Important | type ;
@@ -2338,27 +2354,6 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r
23382354 }
23392355 }
23402356
2341- // Test against block filters
2342- key = BlockAnyParty | type ;
2343- if ( ( bucket = categories [ toHex ( key ) ] ) ) {
2344- if ( this . matchTokens ( bucket , url ) ) {
2345- this . keyRegister = key ;
2346- }
2347- }
2348- if ( this . fRegister === null ) {
2349- key = BlockAction | type | party ;
2350- if ( ( bucket = categories [ toHex ( key ) ] ) ) {
2351- if ( this . matchTokens ( bucket , url ) ) {
2352- this . keyRegister = key ;
2353- }
2354- }
2355- }
2356-
2357- // If there is no block filter, no need to test against allow filters
2358- if ( this . fRegister === null ) {
2359- return undefined ;
2360- }
2361-
23622357 // Test against allow filters
23632358 key = AllowAnyParty | type ;
23642359 if ( ( bucket = categories [ toHex ( key ) ] ) ) {
0 commit comments