1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 17:47:14 +02:00

Do not implicitly strict-block when pattern contains no token char

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1147
This commit is contained in:
Raymond Hill 2020-07-18 09:40:38 -04:00
parent 90868e873c
commit 0549bfaf00
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -243,9 +243,14 @@ const onBeforeRootFrameRequest = function(fctxt) {
// https://github.com/gorhill/uBlock/issues/3208 // https://github.com/gorhill/uBlock/issues/3208
// Mind case insensitivity. // Mind case insensitivity.
// https://github.com/uBlockOrigin/uBlock-issues/issues/1147
// Do not strict-block if the filter pattern does not contain at least one
// token character.
const toBlockDocResult = function(url, hostname, logData) { const toBlockDocResult = function(url, hostname, logData) {
if ( typeof logData.regex !== 'string' ) { return false; } if ( typeof logData.regex !== 'string' ) { return false; }
if ( typeof logData.raw === 'string' && /\w/.test(logData.raw) === false ) {
return false;
}
const re = new RegExp(logData.regex, 'i'); const re = new RegExp(logData.regex, 'i');
const match = re.exec(url.toLowerCase()); const match = re.exec(url.toLowerCase());
if ( match === null ) { return false; } if ( match === null ) { return false; }