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

Properly handle unsupported `nth-child(an of selector)

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1280325910
This commit is contained in:
Raymond Hill 2022-10-17 07:26:51 -04:00
parent 25b0a2c90c
commit 04119e9cdd
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1614,6 +1614,7 @@ Parser.prototype.SelectorCompiler = class {
out.push(`#${data.name}`);
break;
case 'Nth': {
if ( data.selector !== null ) { return; }
if ( data.nth.type === 'AnPlusB' ) {
const a = parseInt(data.nth.a, 10) || null;
const b = parseInt(data.nth.b, 10) || null;
@ -1637,7 +1638,9 @@ Parser.prototype.SelectorCompiler = class {
case 'PseudoElementSelector':
out.push(`:${data.name}`);
if ( Array.isArray(part.args) ) {
out.push(`(${this.astSerialize(part.args)})`);
const arg = this.astSerialize(part.args);
if ( typeof arg !== 'string' ) { return; }
out.push(`(${arg})`);
}
break;
case 'Raw':