1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-24 11:22:44 +01:00

Relax semantic of leading/trailing pipes in filter expressions in logger

This commit is contained in:
Raymond Hill 2018-12-18 13:37:01 -05:00
parent 79905aa798
commit 2e7654d429
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1448,14 +1448,16 @@ const rowFilterer = (function() {
if ( hardEnd ) {
rawPart = rawPart.slice(0, -1);
}
if ( rawPart === '' ) { continue; }
// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
reStr = rawPart.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/51
// Be more flexible when interpreting leading/trailing pipes,
// as leading/trailing pipes are often used in static filters.
if ( hardBeg ) {
reStr = '(?:^|\\s)' + reStr;
reStr = reStr !== '' ? '(?:^|\\s|\\|)' + reStr : '\\|';
}
if ( hardEnd ) {
reStr += '(?:\\s|$)';
reStr += '(?:\\||\\s|$)';
}
}
reStrs.push(reStr);