@adguard/filters-compiler 3.2.6 → 3.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.txt +1 -1
- package/dist/index.cjs +23 -3
- package/dist/index.js +23 -3
- package/package.json +1 -1
package/dist/build.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version=3.2.
|
|
1
|
+
version=3.2.7
|
package/dist/index.cjs
CHANGED
|
@@ -420,15 +420,32 @@ const HTML_RULES_PSEUDO_CLASS_MARKERS = [
|
|
|
420
420
|
':has-text(',
|
|
421
421
|
];
|
|
422
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Markers of length attribute selectors for HTML filtering rules.
|
|
425
|
+
*
|
|
426
|
+
* When the compiler converts [min-length="N"] / [max-length="N"] into
|
|
427
|
+
* :contains() with a regexp quantifier, the quantifier value may exceed
|
|
428
|
+
* the CoreLibs PCRE2 limit of 65535 (UINT16_MAX), causing the rule to
|
|
429
|
+
* silently fail. Since CoreLibs natively supports these attribute selectors
|
|
430
|
+
* and only CoreLibs platforms consume HTML filtering rules from compiler
|
|
431
|
+
* output (all extensions strip $$ rules), we skip the conversion entirely
|
|
432
|
+
* as a temporary workaround.
|
|
433
|
+
*/
|
|
434
|
+
const HTML_RULES_LENGTH_ATTR_MARKERS = [
|
|
435
|
+
'[min-length=',
|
|
436
|
+
'[max-length=',
|
|
437
|
+
];
|
|
438
|
+
|
|
423
439
|
/**
|
|
424
440
|
* Checks if the rule should be kept as is,
|
|
425
441
|
* i.e. no conversion and no validation,
|
|
426
|
-
* since it is not supported by the extension yet
|
|
442
|
+
* since it is not supported by the extension yet
|
|
443
|
+
* or conversion would produce regexes incompatible with CoreLibs.
|
|
427
444
|
*
|
|
428
445
|
* Conditions for keeping the rule as is:
|
|
429
446
|
* - rule is HTML filtering rule
|
|
430
447
|
* - rule is AdGuard syntax
|
|
431
|
-
* - rule contains pseudo-class marker.
|
|
448
|
+
* - rule contains a pseudo-class marker or a length attribute marker.
|
|
432
449
|
*
|
|
433
450
|
* Planned to be fixed:
|
|
434
451
|
* https://github.com/AdguardTeam/tsurlfilter/issues/96.
|
|
@@ -440,7 +457,10 @@ const HTML_RULES_PSEUDO_CLASS_MARKERS = [
|
|
|
440
457
|
const shouldKeepAdgHtmlFilteringRuleAsIs = (ruleNode) => {
|
|
441
458
|
return ruleNode.type === agtree.CosmeticRuleType.HtmlFilteringRule
|
|
442
459
|
&& ruleNode.syntax === agtree.AdblockSyntax.Adg
|
|
443
|
-
&&
|
|
460
|
+
&& (
|
|
461
|
+
HTML_RULES_PSEUDO_CLASS_MARKERS.some((marker) => ruleNode.body.value.includes(marker))
|
|
462
|
+
|| HTML_RULES_LENGTH_ATTR_MARKERS.some((marker) => ruleNode.body.value.includes(marker))
|
|
463
|
+
);
|
|
444
464
|
};
|
|
445
465
|
|
|
446
466
|
/**
|
package/dist/index.js
CHANGED
|
@@ -417,15 +417,32 @@ const HTML_RULES_PSEUDO_CLASS_MARKERS = [
|
|
|
417
417
|
':has-text(',
|
|
418
418
|
];
|
|
419
419
|
|
|
420
|
+
/**
|
|
421
|
+
* Markers of length attribute selectors for HTML filtering rules.
|
|
422
|
+
*
|
|
423
|
+
* When the compiler converts [min-length="N"] / [max-length="N"] into
|
|
424
|
+
* :contains() with a regexp quantifier, the quantifier value may exceed
|
|
425
|
+
* the CoreLibs PCRE2 limit of 65535 (UINT16_MAX), causing the rule to
|
|
426
|
+
* silently fail. Since CoreLibs natively supports these attribute selectors
|
|
427
|
+
* and only CoreLibs platforms consume HTML filtering rules from compiler
|
|
428
|
+
* output (all extensions strip $$ rules), we skip the conversion entirely
|
|
429
|
+
* as a temporary workaround.
|
|
430
|
+
*/
|
|
431
|
+
const HTML_RULES_LENGTH_ATTR_MARKERS = [
|
|
432
|
+
'[min-length=',
|
|
433
|
+
'[max-length=',
|
|
434
|
+
];
|
|
435
|
+
|
|
420
436
|
/**
|
|
421
437
|
* Checks if the rule should be kept as is,
|
|
422
438
|
* i.e. no conversion and no validation,
|
|
423
|
-
* since it is not supported by the extension yet
|
|
439
|
+
* since it is not supported by the extension yet
|
|
440
|
+
* or conversion would produce regexes incompatible with CoreLibs.
|
|
424
441
|
*
|
|
425
442
|
* Conditions for keeping the rule as is:
|
|
426
443
|
* - rule is HTML filtering rule
|
|
427
444
|
* - rule is AdGuard syntax
|
|
428
|
-
* - rule contains pseudo-class marker.
|
|
445
|
+
* - rule contains a pseudo-class marker or a length attribute marker.
|
|
429
446
|
*
|
|
430
447
|
* Planned to be fixed:
|
|
431
448
|
* https://github.com/AdguardTeam/tsurlfilter/issues/96.
|
|
@@ -437,7 +454,10 @@ const HTML_RULES_PSEUDO_CLASS_MARKERS = [
|
|
|
437
454
|
const shouldKeepAdgHtmlFilteringRuleAsIs = (ruleNode) => {
|
|
438
455
|
return ruleNode.type === CosmeticRuleType.HtmlFilteringRule
|
|
439
456
|
&& ruleNode.syntax === AdblockSyntax.Adg
|
|
440
|
-
&&
|
|
457
|
+
&& (
|
|
458
|
+
HTML_RULES_PSEUDO_CLASS_MARKERS.some((marker) => ruleNode.body.value.includes(marker))
|
|
459
|
+
|| HTML_RULES_LENGTH_ATTR_MARKERS.some((marker) => ruleNode.body.value.includes(marker))
|
|
460
|
+
);
|
|
441
461
|
};
|
|
442
462
|
|
|
443
463
|
/**
|