@adguard/agtree 3.4.1 → 4.0.0
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/ast-utils/clone.js +2 -2
- package/dist/ast-utils/modifiers.js +2 -2
- package/dist/ast-utils/network-rules.js +2 -2
- package/dist/ast-utils/scriptlets.js +2 -2
- package/dist/common/abp-snippet-injection-body-common.js +2 -2
- package/dist/common/agent-common.js +2 -2
- package/dist/common/ubo-html-filtering-body-common.js +40 -0
- package/dist/common/ubo-selector-common.js +2 -2
- package/dist/compatibility-tables/base.js +2 -2
- package/dist/compatibility-tables/compatibility-table-data.js +4 -4
- package/dist/compatibility-tables/modifiers.js +2 -2
- package/dist/compatibility-tables/platforms.js +2 -2
- package/dist/compatibility-tables/redirects.js +2 -2
- package/dist/compatibility-tables/schemas/base.js +2 -2
- package/dist/compatibility-tables/schemas/modifier.js +2 -2
- package/dist/compatibility-tables/schemas/platform.js +2 -2
- package/dist/compatibility-tables/schemas/redirect.js +2 -2
- package/dist/compatibility-tables/schemas/resource-type.js +2 -2
- package/dist/compatibility-tables/schemas/scriptlet.js +2 -2
- package/dist/compatibility-tables/scriptlets.js +2 -2
- package/dist/compatibility-tables/utils/platform-helpers.js +2 -2
- package/dist/compatibility-tables/utils/resource-type-helpers.js +2 -2
- package/dist/compatibility-tables/utils/zod-camelcase.js +2 -2
- package/dist/converter/base-interfaces/base-converter.js +2 -2
- package/dist/converter/base-interfaces/conversion-result.js +2 -2
- package/dist/converter/base-interfaces/rule-converter-base.js +2 -2
- package/dist/converter/comment/index.js +2 -2
- package/dist/converter/cosmetic/css.js +2 -2
- package/dist/converter/cosmetic/element-hiding.js +2 -2
- package/dist/converter/cosmetic/header-removal.js +24 -42
- package/dist/converter/cosmetic/html.js +580 -438
- package/dist/converter/cosmetic/index.js +3 -2
- package/dist/converter/cosmetic/rule-modifiers/adg.js +2 -2
- package/dist/converter/cosmetic/rule-modifiers/ubo.js +2 -2
- package/dist/converter/cosmetic/scriptlet.js +2 -2
- package/dist/converter/css/index.js +3 -2
- package/dist/converter/data/css.js +32 -54
- package/dist/converter/filter-list.js +2 -2
- package/dist/converter/index.js +2 -2
- package/dist/converter/misc/network-rule-modifier.js +2 -2
- package/dist/converter/network/index.js +2 -2
- package/dist/converter/raw-filter-list.js +2 -2
- package/dist/converter/raw-rule.js +6 -3
- package/dist/converter/rule.js +2 -2
- package/dist/errors/adblock-syntax-error.js +2 -2
- package/dist/errors/binary-schema-mismatch-error.js +2 -2
- package/dist/errors/not-implemented-error.js +2 -2
- package/dist/errors/rule-conversion-error.js +2 -2
- package/dist/generator/base-generator.js +2 -2
- package/dist/generator/comment/agent-comment-generator.js +2 -2
- package/dist/generator/comment/agent-generator.js +2 -2
- package/dist/generator/comment/comment-rule-generator.js +2 -2
- package/dist/generator/comment/config-comment-generator.js +2 -2
- package/dist/generator/comment/hint-comment-generator.js +2 -2
- package/dist/generator/comment/hint-generator.js +2 -2
- package/dist/generator/comment/metadata-comment-generator.js +2 -2
- package/dist/generator/comment/pre-processor-comment-generator.js +2 -2
- package/dist/generator/comment/simple-comment-generator.js +2 -2
- package/dist/generator/cosmetic/cosmetic-rule-body-generator.js +21 -6
- package/dist/generator/cosmetic/cosmetic-rule-generator.js +2 -2
- package/dist/generator/cosmetic/cosmetic-rule-pattern-generator.js +2 -2
- package/dist/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.js +38 -0
- package/dist/generator/cosmetic/html-filtering-body/html-filtering-body-generator.js +32 -0
- package/dist/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.js +65 -0
- package/dist/generator/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-generator.js +2 -2
- package/dist/generator/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-generator.js +2 -2
- package/dist/generator/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-generator.js +2 -2
- package/dist/generator/cosmetic/selector/attribute-selector-generator.js +42 -0
- package/dist/generator/cosmetic/selector/class-selector-generator.js +26 -0
- package/dist/generator/cosmetic/selector/complex-selector-generator.js +71 -0
- package/dist/generator/cosmetic/selector/id-selector-generator.js +26 -0
- package/dist/generator/cosmetic/selector/pseudo-class-selector-generator.js +35 -0
- package/dist/generator/cosmetic/selector/selector-combinator-generator.js +30 -0
- package/dist/generator/cosmetic/selector/selector-list-generator.js +41 -0
- package/dist/generator/cosmetic/selector/type-selector-generator.js +25 -0
- package/dist/generator/css/adg-css-injection-generator.js +5 -6
- package/dist/generator/filterlist-generator.js +2 -2
- package/dist/generator/index.js +2 -2
- package/dist/generator/misc/domain-list-generator.js +2 -2
- package/dist/generator/misc/list-items-generator.js +2 -2
- package/dist/generator/misc/logical-expression-generator.js +2 -2
- package/dist/generator/misc/modifier-generator.js +2 -2
- package/dist/generator/misc/modifier-list-generator.js +2 -2
- package/dist/generator/misc/parameter-list-generator.js +2 -2
- package/dist/generator/misc/value-generator.js +2 -2
- package/dist/generator/network/host-rule-generator.js +2 -2
- package/dist/generator/network/network-rule-generator.js +2 -2
- package/dist/generator/rule-generator.js +2 -2
- package/dist/index.js +4 -14
- package/dist/nodes/index.js +2 -2
- package/dist/package.json.js +3 -3
- package/dist/parser/base-parser.js +2 -2
- package/dist/parser/comment/agent-comment-parser.js +2 -2
- package/dist/parser/comment/agent-parser.js +2 -2
- package/dist/parser/comment/comment-parser.js +2 -2
- package/dist/parser/comment/config-comment-parser.js +2 -2
- package/dist/parser/comment/hint-comment-parser.js +2 -2
- package/dist/parser/comment/hint-parser.js +2 -2
- package/dist/parser/comment/metadata-comment-parser.js +2 -2
- package/dist/parser/comment/preprocessor-parser.js +2 -2
- package/dist/parser/comment/simple-comment-parser.js +2 -2
- package/dist/parser/cosmetic/cosmetic-rule-parser.js +10 -21
- package/dist/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.js +49 -0
- package/dist/parser/cosmetic/html-filtering-body/html-filtering-body-parser.js +70 -0
- package/dist/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.js +180 -0
- package/dist/parser/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-parser.js +2 -2
- package/dist/parser/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-parser.js +2 -2
- package/dist/parser/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-parser.js +2 -2
- package/dist/parser/cosmetic/selector/handlers/attribute-selector-handler.js +206 -0
- package/dist/parser/cosmetic/selector/handlers/class-selector-handler.js +48 -0
- package/dist/parser/cosmetic/selector/handlers/complex-selector-handler.js +67 -0
- package/dist/parser/cosmetic/selector/handlers/compound-selector-handler.js +97 -0
- package/dist/parser/cosmetic/selector/handlers/id-selector-handler.js +42 -0
- package/dist/parser/cosmetic/selector/handlers/pseudo-class-selector-handler.js +128 -0
- package/dist/parser/cosmetic/selector/handlers/type-selector-handler.js +58 -0
- package/dist/parser/cosmetic/selector/selector-list-parser.js +164 -0
- package/dist/parser/css/adg-css-injection-parser.js +4 -5
- package/dist/parser/css/balancing.js +2 -2
- package/dist/parser/css/constants.js +2 -2
- package/dist/parser/css/css-token-stream.js +41 -4
- package/dist/parser/css/ubo-selector-parser.js +2 -2
- package/dist/parser/filterlist-parser.js +2 -2
- package/dist/parser/index.js +2 -2
- package/dist/parser/misc/app-list-parser.js +2 -2
- package/dist/parser/misc/domain-list-parser.js +2 -2
- package/dist/parser/misc/list-items-parser.js +2 -2
- package/dist/parser/misc/logical-expression-parser.js +2 -2
- package/dist/parser/misc/method-list-parser.js +2 -2
- package/dist/parser/misc/modifier-list.js +9 -3
- package/dist/parser/misc/modifier-parser.js +2 -2
- package/dist/parser/misc/parameter-list-parser.js +2 -2
- package/dist/parser/misc/stealth-option-list-parser.js +2 -2
- package/dist/parser/misc/ubo-parameter-list-parser.js +2 -2
- package/dist/parser/misc/value-parser.js +2 -2
- package/dist/parser/network/host-rule-parser.js +2 -2
- package/dist/parser/network/network-rule-parser.js +2 -2
- package/dist/parser/options.js +3 -2
- package/dist/parser/rule-parser.js +2 -2
- package/dist/types/common/ubo-html-filtering-body-common.d.ts +12 -0
- package/dist/types/compatibility-tables/compatibility-table-data.d.ts +3 -3
- package/dist/types/compatibility-tables/schemas/redirect.d.ts +1 -1
- package/dist/types/compatibility-tables/schemas/scriptlet.d.ts +2 -2
- package/dist/types/converter/cosmetic/html.d.ts +167 -42
- package/dist/types/converter/data/css.d.ts +18 -6
- package/dist/types/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.d.ts +17 -0
- package/dist/types/generator/cosmetic/html-filtering-body/html-filtering-body-generator.d.ts +17 -0
- package/dist/types/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.d.ts +30 -0
- package/dist/types/generator/cosmetic/selector/attribute-selector-generator.d.ts +15 -0
- package/dist/types/generator/cosmetic/selector/class-selector-generator.d.ts +15 -0
- package/dist/types/generator/cosmetic/selector/complex-selector-generator.d.ts +17 -0
- package/dist/types/generator/cosmetic/selector/id-selector-generator.d.ts +15 -0
- package/dist/types/generator/cosmetic/selector/pseudo-class-selector-generator.d.ts +15 -0
- package/dist/types/generator/cosmetic/selector/selector-combinator-generator.d.ts +15 -0
- package/dist/types/generator/cosmetic/selector/selector-list-generator.d.ts +17 -0
- package/dist/types/generator/cosmetic/selector/type-selector-generator.d.ts +15 -0
- package/dist/types/generator/css/adg-css-injection-generator.d.ts +1 -1
- package/dist/types/index.d.ts +3 -13
- package/dist/types/nodes/index.d.ts +159 -3
- package/dist/types/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.d.ts +35 -0
- package/dist/types/parser/cosmetic/html-filtering-body/html-filtering-body-parser.d.ts +39 -0
- package/dist/types/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.d.ts +63 -0
- package/dist/types/parser/cosmetic/selector/context.d.ts +42 -0
- package/dist/types/parser/cosmetic/selector/handlers/attribute-selector-handler.d.ts +35 -0
- package/dist/types/parser/cosmetic/selector/handlers/class-selector-handler.d.ts +15 -0
- package/dist/types/parser/cosmetic/selector/handlers/complex-selector-handler.d.ts +20 -0
- package/dist/types/parser/cosmetic/selector/handlers/compound-selector-handler.d.ts +25 -0
- package/dist/types/parser/cosmetic/selector/handlers/id-selector-handler.d.ts +15 -0
- package/dist/types/parser/cosmetic/selector/handlers/pseudo-class-selector-handler.d.ts +15 -0
- package/dist/types/parser/cosmetic/selector/handlers/type-selector-handler.d.ts +15 -0
- package/dist/types/parser/cosmetic/selector/selector-list-parser.d.ts +38 -0
- package/dist/types/parser/css/adg-css-injection-parser.d.ts +0 -2
- package/dist/types/parser/css/css-token-stream.d.ts +18 -0
- package/dist/types/parser/network/network-rule-parser.d.ts +1 -1
- package/dist/types/parser/options.d.ts +5 -0
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/quotes.d.ts +44 -0
- package/dist/types/utils/regexp.d.ts +24 -0
- package/dist/utils/adblockers.js +2 -2
- package/dist/utils/bit-count.js +2 -2
- package/dist/utils/categorizer.js +2 -2
- package/dist/utils/clone.js +2 -2
- package/dist/utils/constants.js +6 -9
- package/dist/utils/cosmetic-rule-separator.js +2 -2
- package/dist/utils/deep-freeze.js +2 -2
- package/dist/utils/domain.js +2 -2
- package/dist/utils/error.js +2 -2
- package/dist/utils/index.js +2 -8
- package/dist/utils/logical-expression.js +2 -2
- package/dist/utils/multi-value-map.js +2 -2
- package/dist/utils/noop-modifier.js +2 -2
- package/dist/utils/position-provider.js +2 -2
- package/dist/utils/quotes.js +163 -10
- package/dist/utils/regexp.js +31 -2
- package/dist/utils/string.js +2 -2
- package/dist/utils/type-guards.js +3 -13
- package/dist/validator/constants.js +2 -2
- package/dist/validator/helpers.js +2 -2
- package/dist/validator/index.js +2 -2
- package/dist/validator/value.js +2 -2
- package/dist/version.js +2 -2
- package/package.json +8 -16
- package/dist/deserializer/base-deserializer.js +0 -29
- package/dist/deserializer/comment/agent-comment-deserializer.js +0 -79
- package/dist/deserializer/comment/agent-deserializer.js +0 -65
- package/dist/deserializer/comment/comment-rule-deserializer.js +0 -54
- package/dist/deserializer/comment/config-comment-deserializer.js +0 -111
- package/dist/deserializer/comment/hint-comment-deserializer.js +0 -72
- package/dist/deserializer/comment/hint-deserializer.js +0 -85
- package/dist/deserializer/comment/metadata-comment-deserializer.js +0 -69
- package/dist/deserializer/comment/pre-processor-comment-deserializer.js +0 -112
- package/dist/deserializer/comment/simple-comment-deserializer.js +0 -65
- package/dist/deserializer/cosmetic/cosmetic-rule-deserializer.js +0 -131
- package/dist/deserializer/cosmetic/css-injection-body-deserializer.js +0 -56
- package/dist/deserializer/cosmetic/element-hiding-body-deserializer.js +0 -48
- package/dist/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.js +0 -39
- package/dist/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.js +0 -40
- package/dist/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.js +0 -54
- package/dist/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.js +0 -38
- package/dist/deserializer/empty-rule-deserializer.js +0 -48
- package/dist/deserializer/filterlist-deserializer.js +0 -85
- package/dist/deserializer/index.js +0 -8
- package/dist/deserializer/invalid-rule-deserializer.js +0 -50
- package/dist/deserializer/invalid-rule-error-node-deserializer.js +0 -50
- package/dist/deserializer/misc/domain-list-deserializer.js +0 -64
- package/dist/deserializer/misc/list-item-deserializer.js +0 -69
- package/dist/deserializer/misc/list-items-deserializer.js +0 -30
- package/dist/deserializer/misc/logical-expression-deserializer.js +0 -196
- package/dist/deserializer/misc/modifier-deserializer.js +0 -87
- package/dist/deserializer/misc/modifier-list-deserializer.js +0 -61
- package/dist/deserializer/misc/parameter-list-deserializer.js +0 -64
- package/dist/deserializer/misc/value-deserializer.js +0 -50
- package/dist/deserializer/network/host-rule-deserializer.js +0 -67
- package/dist/deserializer/network/hostname-list-deserializer.js +0 -56
- package/dist/deserializer/network/network-rule-deserializer.js +0 -65
- package/dist/deserializer/rule-deserializer.js +0 -65
- package/dist/deserializer/syntax-deserialization-map.js +0 -21
- package/dist/marshalling-utils/comment/agent-comment-common.js +0 -21
- package/dist/marshalling-utils/comment/agent-common.js +0 -40
- package/dist/marshalling-utils/comment/config-comment-common.js +0 -54
- package/dist/marshalling-utils/comment/hint-comment-common.js +0 -22
- package/dist/marshalling-utils/comment/hint-common.js +0 -56
- package/dist/marshalling-utils/comment/metadata-comment-common.js +0 -41
- package/dist/marshalling-utils/comment/pre-processor-comment-common.js +0 -59
- package/dist/marshalling-utils/comment/simple-comment-common.js +0 -22
- package/dist/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.js +0 -61
- package/dist/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.js +0 -66
- package/dist/marshalling-utils/cosmetic/body/css-injection-body-common.js +0 -24
- package/dist/marshalling-utils/cosmetic/body/element-hiding-body-common.js +0 -21
- package/dist/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.js +0 -114
- package/dist/marshalling-utils/cosmetic/cosmetic-rule-common.js +0 -46
- package/dist/marshalling-utils/empty-rule-common.js +0 -20
- package/dist/marshalling-utils/filter-list-common.js +0 -21
- package/dist/marshalling-utils/invalid-rule-common.js +0 -21
- package/dist/marshalling-utils/invalid-rule-error-node-common.js +0 -22
- package/dist/marshalling-utils/misc/binary-type-common.js +0 -54
- package/dist/marshalling-utils/misc/domain-list-common.js +0 -36
- package/dist/marshalling-utils/misc/host-rule-common.js +0 -24
- package/dist/marshalling-utils/misc/hostname-list-common.js +0 -21
- package/dist/marshalling-utils/misc/list-item-common.js +0 -22
- package/dist/marshalling-utils/misc/logical-expression-common.js +0 -83
- package/dist/marshalling-utils/misc/modifier-common.js +0 -231
- package/dist/marshalling-utils/misc/modifier-list-common.js +0 -21
- package/dist/marshalling-utils/misc/parameter-list-common.js +0 -21
- package/dist/marshalling-utils/misc/value-common.js +0 -22
- package/dist/marshalling-utils/network/network-rule-common.js +0 -24
- package/dist/marshalling-utils/syntax-serialization-map.js +0 -30
- package/dist/serializer/base-serializer.js +0 -29
- package/dist/serializer/comment/agent-comment-serializer.js +0 -74
- package/dist/serializer/comment/agent-serializer.js +0 -59
- package/dist/serializer/comment/comment-rule-serializer.js +0 -105
- package/dist/serializer/comment/config-comment-serializer.js +0 -82
- package/dist/serializer/comment/hint-comment-serializer.js +0 -65
- package/dist/serializer/comment/hint-serializer.js +0 -54
- package/dist/serializer/comment/metadata-comment-serializer.js +0 -73
- package/dist/serializer/comment/pre-processor-comment-serializer.js +0 -71
- package/dist/serializer/comment/simple-comment-serializer.js +0 -52
- package/dist/serializer/cosmetic/body/abp-snippet-injection-body-serializer.js +0 -36
- package/dist/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.js +0 -36
- package/dist/serializer/cosmetic/body/scriptlet-body-serializer.js +0 -50
- package/dist/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.js +0 -36
- package/dist/serializer/cosmetic/cosmetic-rule-serializer.js +0 -120
- package/dist/serializer/cosmetic/css-injection-body-serializer.js +0 -51
- package/dist/serializer/cosmetic/element-hiding-body-serializer.js +0 -40
- package/dist/serializer/empty-rule-serializer.js +0 -37
- package/dist/serializer/filterlist-serializer.js +0 -45
- package/dist/serializer/index.js +0 -7
- package/dist/serializer/invalid-rule-error-node-serializer.js +0 -41
- package/dist/serializer/invalid-rule-serializer.js +0 -40
- package/dist/serializer/misc/domain-list-serializer.js +0 -64
- package/dist/serializer/misc/list-item-serializer.js +0 -58
- package/dist/serializer/misc/list-items-serializer.js +0 -29
- package/dist/serializer/misc/logical-expression-serializer.js +0 -136
- package/dist/serializer/misc/modifier-list-serializer.js +0 -58
- package/dist/serializer/misc/modifier-serializer.js +0 -49
- package/dist/serializer/misc/parameter-list-serializer.js +0 -52
- package/dist/serializer/misc/value-serializer.js +0 -50
- package/dist/serializer/network/host-rule-serializer.js +0 -70
- package/dist/serializer/network/hostname-list-serializer.js +0 -53
- package/dist/serializer/network/network-rule-serializer.js +0 -54
- package/dist/serializer/rule-serializer.js +0 -61
- package/dist/types/deserializer/base-deserializer.d.ts +0 -15
- package/dist/types/deserializer/comment/agent-comment-deserializer.d.ts +0 -34
- package/dist/types/deserializer/comment/agent-deserializer.d.ts +0 -25
- package/dist/types/deserializer/comment/comment-rule-deserializer.d.ts +0 -16
- package/dist/types/deserializer/comment/config-comment-deserializer.d.ts +0 -27
- package/dist/types/deserializer/comment/hint-comment-deserializer.d.ts +0 -24
- package/dist/types/deserializer/comment/hint-deserializer.d.ts +0 -26
- package/dist/types/deserializer/comment/metadata-comment-deserializer.d.ts +0 -26
- package/dist/types/deserializer/comment/pre-processor-comment-deserializer.d.ts +0 -29
- package/dist/types/deserializer/comment/simple-comment-deserializer.d.ts +0 -26
- package/dist/types/deserializer/cosmetic/cosmetic-rule-deserializer.d.ts +0 -18
- package/dist/types/deserializer/cosmetic/css-injection-body-deserializer.d.ts +0 -15
- package/dist/types/deserializer/cosmetic/element-hiding-body-deserializer.d.ts +0 -16
- package/dist/types/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.d.ts +0 -17
- package/dist/types/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.d.ts +0 -18
- package/dist/types/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.d.ts +0 -19
- package/dist/types/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.d.ts +0 -17
- package/dist/types/deserializer/empty-rule-deserializer.d.ts +0 -16
- package/dist/types/deserializer/filterlist-deserializer.d.ts +0 -34
- package/dist/types/deserializer/index.d.ts +0 -2
- package/dist/types/deserializer/invalid-rule-deserializer.d.ts +0 -16
- package/dist/types/deserializer/invalid-rule-error-node-deserializer.d.ts +0 -16
- package/dist/types/deserializer/misc/domain-list-deserializer.d.ts +0 -15
- package/dist/types/deserializer/misc/list-item-deserializer.d.ts +0 -19
- package/dist/types/deserializer/misc/list-items-deserializer.d.ts +0 -16
- package/dist/types/deserializer/misc/logical-expression-deserializer.d.ts +0 -55
- package/dist/types/deserializer/misc/modifier-deserializer.d.ts +0 -18
- package/dist/types/deserializer/misc/modifier-list-deserializer.d.ts +0 -20
- package/dist/types/deserializer/misc/parameter-list-deserializer.d.ts +0 -18
- package/dist/types/deserializer/misc/value-deserializer.d.ts +0 -17
- package/dist/types/deserializer/network/host-rule-deserializer.d.ts +0 -18
- package/dist/types/deserializer/network/hostname-list-deserializer.d.ts +0 -15
- package/dist/types/deserializer/network/network-rule-deserializer.d.ts +0 -18
- package/dist/types/deserializer/rule-deserializer.d.ts +0 -17
- package/dist/types/deserializer/syntax-deserialization-map.d.ts +0 -2
- package/dist/types/marshalling-utils/comment/agent-comment-common.d.ts +0 -14
- package/dist/types/marshalling-utils/comment/agent-common.d.ts +0 -20
- package/dist/types/marshalling-utils/comment/config-comment-common.d.ts +0 -42
- package/dist/types/marshalling-utils/comment/hint-comment-common.d.ts +0 -15
- package/dist/types/marshalling-utils/comment/hint-common.d.ts +0 -33
- package/dist/types/marshalling-utils/comment/metadata-comment-common.d.ts +0 -21
- package/dist/types/marshalling-utils/comment/pre-processor-comment-common.d.ts +0 -37
- package/dist/types/marshalling-utils/comment/simple-comment-common.d.ts +0 -15
- package/dist/types/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.d.ts +0 -23
- package/dist/types/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.d.ts +0 -9
- package/dist/types/marshalling-utils/cosmetic/body/css-injection-body-common.d.ts +0 -17
- package/dist/types/marshalling-utils/cosmetic/body/element-hiding-body-common.d.ts +0 -14
- package/dist/types/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.d.ts +0 -9
- package/dist/types/marshalling-utils/cosmetic/cosmetic-rule-common.d.ts +0 -28
- package/dist/types/marshalling-utils/empty-rule-common.d.ts +0 -13
- package/dist/types/marshalling-utils/filter-list-common.d.ts +0 -14
- package/dist/types/marshalling-utils/invalid-rule-common.d.ts +0 -14
- package/dist/types/marshalling-utils/invalid-rule-error-node-common.d.ts +0 -15
- package/dist/types/marshalling-utils/misc/binary-type-common.d.ts +0 -57
- package/dist/types/marshalling-utils/misc/domain-list-common.d.ts +0 -24
- package/dist/types/marshalling-utils/misc/host-rule-common.d.ts +0 -18
- package/dist/types/marshalling-utils/misc/hostname-list-common.d.ts +0 -14
- package/dist/types/marshalling-utils/misc/list-item-common.d.ts +0 -15
- package/dist/types/marshalling-utils/misc/logical-expression-common.d.ts +0 -47
- package/dist/types/marshalling-utils/misc/modifier-common.d.ts +0 -41
- package/dist/types/marshalling-utils/misc/modifier-list-common.d.ts +0 -14
- package/dist/types/marshalling-utils/misc/parameter-list-common.d.ts +0 -14
- package/dist/types/marshalling-utils/misc/value-common.d.ts +0 -15
- package/dist/types/marshalling-utils/network/network-rule-common.d.ts +0 -18
- package/dist/types/marshalling-utils/syntax-serialization-map.d.ts +0 -2
- package/dist/types/serializer/base-serializer.d.ts +0 -15
- package/dist/types/serializer/comment/agent-comment-serializer.d.ts +0 -34
- package/dist/types/serializer/comment/agent-serializer.d.ts +0 -15
- package/dist/types/serializer/comment/comment-rule-serializer.d.ts +0 -68
- package/dist/types/serializer/comment/config-comment-serializer.d.ts +0 -25
- package/dist/types/serializer/comment/hint-comment-serializer.d.ts +0 -23
- package/dist/types/serializer/comment/hint-serializer.d.ts +0 -24
- package/dist/types/serializer/comment/metadata-comment-serializer.d.ts +0 -25
- package/dist/types/serializer/comment/pre-processor-comment-serializer.d.ts +0 -28
- package/dist/types/serializer/comment/simple-comment-serializer.d.ts +0 -24
- package/dist/types/serializer/cosmetic/body/abp-snippet-injection-body-serializer.d.ts +0 -25
- package/dist/types/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.d.ts +0 -25
- package/dist/types/serializer/cosmetic/body/scriptlet-body-serializer.d.ts +0 -17
- package/dist/types/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.d.ts +0 -25
- package/dist/types/serializer/cosmetic/cosmetic-rule-serializer.d.ts +0 -19
- package/dist/types/serializer/cosmetic/css-injection-body-serializer.d.ts +0 -15
- package/dist/types/serializer/cosmetic/element-hiding-body-serializer.d.ts +0 -15
- package/dist/types/serializer/empty-rule-serializer.d.ts +0 -15
- package/dist/types/serializer/filterlist-serializer.d.ts +0 -15
- package/dist/types/serializer/index.d.ts +0 -1
- package/dist/types/serializer/invalid-rule-error-node-serializer.d.ts +0 -15
- package/dist/types/serializer/invalid-rule-serializer.d.ts +0 -15
- package/dist/types/serializer/misc/domain-list-serializer.d.ts +0 -21
- package/dist/types/serializer/misc/list-item-serializer.d.ts +0 -16
- package/dist/types/serializer/misc/list-items-serializer.d.ts +0 -15
- package/dist/types/serializer/misc/logical-expression-serializer.d.ts +0 -52
- package/dist/types/serializer/misc/modifier-list-serializer.d.ts +0 -20
- package/dist/types/serializer/misc/modifier-serializer.d.ts +0 -18
- package/dist/types/serializer/misc/parameter-list-serializer.d.ts +0 -17
- package/dist/types/serializer/misc/value-serializer.d.ts +0 -17
- package/dist/types/serializer/network/host-rule-serializer.d.ts +0 -30
- package/dist/types/serializer/network/hostname-list-serializer.d.ts +0 -15
- package/dist/types/serializer/network/network-rule-serializer.d.ts +0 -18
- package/dist/types/serializer/rule-serializer.d.ts +0 -17
- package/dist/types/utils/binary-schema-version.d.ts +0 -9
- package/dist/types/utils/byte-buffer.d.ts +0 -54
- package/dist/types/utils/input-byte-buffer.d.ts +0 -146
- package/dist/types/utils/is-chromium.d.ts +0 -7
- package/dist/types/utils/output-byte-buffer.d.ts +0 -132
- package/dist/types/utils/storage-interface.d.ts +0 -23
- package/dist/types/utils/text-decoder-polyfill.d.ts +0 -14
- package/dist/types/utils/text-encoder-polyfill.d.ts +0 -18
- package/dist/utils/binary-schema-version.js +0 -17
- package/dist/utils/byte-buffer.js +0 -91
- package/dist/utils/input-byte-buffer.js +0 -266
- package/dist/utils/is-chromium.js +0 -20
- package/dist/utils/output-byte-buffer.js +0 -231
- package/dist/utils/text-decoder-polyfill.js +0 -107
- package/dist/utils/text-encoder-polyfill.js +0 -78
- /package/dist/types/generator/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-generator.d.ts +0 -0
- /package/dist/types/generator/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-generator.d.ts +0 -0
- /package/dist/types/generator/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-generator.d.ts +0 -0
- /package/dist/types/parser/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-parser.d.ts +0 -0
- /package/dist/types/parser/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-parser.d.ts +0 -0
- /package/dist/types/parser/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-parser.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
@@ -18,9 +18,11 @@ import { CommentParser } from '../comment/comment-parser.js';
|
|
|
18
18
|
import { defaultParserOptions } from '../options.js';
|
|
19
19
|
import { UboSelectorParser } from '../css/ubo-selector-parser.js';
|
|
20
20
|
import { AdgCssInjectionParser } from '../css/adg-css-injection-parser.js';
|
|
21
|
-
import { AbpSnippetInjectionBodyParser } from './body/abp-snippet-injection-body-parser.js';
|
|
22
|
-
import { UboScriptletInjectionBodyParser } from './body/ubo-scriptlet-injection-body-parser.js';
|
|
23
|
-
import { AdgScriptletInjectionBodyParser } from './body/adg-scriptlet-injection-body-parser.js';
|
|
21
|
+
import { AbpSnippetInjectionBodyParser } from './scriptlet-body/abp-snippet-injection-body-parser.js';
|
|
22
|
+
import { UboScriptletInjectionBodyParser } from './scriptlet-body/ubo-scriptlet-injection-body-parser.js';
|
|
23
|
+
import { AdgScriptletInjectionBodyParser } from './scriptlet-body/adg-scriptlet-injection-body-parser.js';
|
|
24
|
+
import { AdgHtmlFilteringBodyParser } from './html-filtering-body/adg-html-filtering-body-parser.js';
|
|
25
|
+
import { UboHtmlFilteringBodyParser } from './html-filtering-body/ubo-html-filtering-body-parser.js';
|
|
24
26
|
import { BaseParser } from '../base-parser.js';
|
|
25
27
|
import { UboPseudoName } from '../../common/ubo-selector-common.js';
|
|
26
28
|
|
|
@@ -412,14 +414,8 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
412
414
|
throw new AdblockSyntaxError(sprintf(ERROR_MESSAGES.SYNTAX_DISABLED, AdblockSyntax.Ubo), baseOffset + bodyStart, baseOffset + bodyEnd);
|
|
413
415
|
}
|
|
414
416
|
expectCommonOrSpecificSyntax(AdblockSyntax.Ubo);
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
value: rawBody,
|
|
418
|
-
};
|
|
419
|
-
if (options.isLocIncluded) {
|
|
420
|
-
body.start = baseOffset + bodyStart;
|
|
421
|
-
body.end = baseOffset + bodyEnd;
|
|
422
|
-
}
|
|
417
|
+
const rawBodyWithoutMask = rawBody.slice(UBO_HTML_MASK.length);
|
|
418
|
+
const body = UboHtmlFilteringBodyParser.parse(rawBodyWithoutMask, options, baseOffset + bodyStart + UBO_HTML_MASK.length);
|
|
423
419
|
return {
|
|
424
420
|
syntax: AdblockSyntax.Ubo,
|
|
425
421
|
type: CosmeticRuleType.HtmlFilteringRule,
|
|
@@ -428,14 +424,7 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
428
424
|
};
|
|
429
425
|
const parseAdgHtmlFiltering = () => {
|
|
430
426
|
expectCommonOrSpecificSyntax(AdblockSyntax.Adg);
|
|
431
|
-
const body =
|
|
432
|
-
type: 'Value',
|
|
433
|
-
value: rawBody,
|
|
434
|
-
};
|
|
435
|
-
if (options.isLocIncluded) {
|
|
436
|
-
body.start = baseOffset + bodyStart;
|
|
437
|
-
body.end = baseOffset + bodyEnd;
|
|
438
|
-
}
|
|
427
|
+
const body = AdgHtmlFilteringBodyParser.parse(rawBody, options, baseOffset + bodyStart);
|
|
439
428
|
return {
|
|
440
429
|
syntax: AdblockSyntax.Adg,
|
|
441
430
|
type: CosmeticRuleType.HtmlFilteringRule,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
|
+
*/
|
|
7
|
+
import { QuoteUtils } from '../../../utils/quotes.js';
|
|
8
|
+
import { BaseParser } from '../../base-parser.js';
|
|
9
|
+
import { defaultParserOptions } from '../../options.js';
|
|
10
|
+
import { HtmlFilteringBodyParser } from './html-filtering-body-parser.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `AdgHtmlFilteringBodyParser` is responsible for parsing the body of an AdGuard-style HTML filtering rule.
|
|
14
|
+
*
|
|
15
|
+
* Please note that the parser will parse any HTML filtering rule if it is syntactically correct.
|
|
16
|
+
* For example, it will parse this:
|
|
17
|
+
* ```adblock
|
|
18
|
+
* example.com$$div[special-attr="value"]
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* but it didn't check if the attribute `special-attr` actually supported by any adblocker.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
24
|
+
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#html-filtering-rules}
|
|
25
|
+
*/
|
|
26
|
+
class AdgHtmlFilteringBodyParser extends BaseParser {
|
|
27
|
+
/**
|
|
28
|
+
* Parses the body of an AdGuard-style HTML filtering rule.
|
|
29
|
+
*
|
|
30
|
+
* @param raw Raw input to parse.
|
|
31
|
+
* @param options Global parser options.
|
|
32
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
33
|
+
*
|
|
34
|
+
* @returns Node of the parsed HTML filtering rule body.
|
|
35
|
+
*
|
|
36
|
+
* @throws If the body is syntactically incorrect.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```
|
|
40
|
+
* div[some_attribute="some_value"]
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
44
|
+
const escapedRaw = QuoteUtils.escapeAttributeDoubleQuotes(raw);
|
|
45
|
+
return HtmlFilteringBodyParser.parse(escapedRaw, options, baseOffset);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { AdgHtmlFilteringBodyParser };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
|
+
*/
|
|
7
|
+
import { BaseParser } from '../../base-parser.js';
|
|
8
|
+
import { defaultParserOptions } from '../../options.js';
|
|
9
|
+
import { SelectorListParser } from '../selector/selector-list-parser.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Class responsible for parsing HTML filtering rule body.
|
|
13
|
+
*
|
|
14
|
+
* Please note that the parser will parse any HTML filtering rule body if it is syntactically correct.
|
|
15
|
+
* For example, it will parse this:
|
|
16
|
+
* ```adblock
|
|
17
|
+
* span[special-attr="Example"]
|
|
18
|
+
* div:special-pseudo(Example)
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* but it didn't check if the pseudo selector `special-pseudo` or if
|
|
22
|
+
* the attribute selector `special-attr` actually supported by any adblocker.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
25
|
+
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#html-filtering-rules}
|
|
26
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#html-filters}
|
|
27
|
+
*/
|
|
28
|
+
class HtmlFilteringBodyParser extends BaseParser {
|
|
29
|
+
/**
|
|
30
|
+
* Parses a HTML filtering rule body.
|
|
31
|
+
*
|
|
32
|
+
* @param raw Raw input to parse.
|
|
33
|
+
* @param options Global parser options.
|
|
34
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
35
|
+
*
|
|
36
|
+
* @returns Node of the parsed HTML filtering rule body.
|
|
37
|
+
*
|
|
38
|
+
* @throws If the body is syntactically incorrect.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```
|
|
42
|
+
* span[tag-content="Example"]
|
|
43
|
+
* div:has-text(Example)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
47
|
+
// If HTML filtering rules parsing is disabled, return raw value node
|
|
48
|
+
let result;
|
|
49
|
+
if (options.parseHtmlFilteringRuleBodies) {
|
|
50
|
+
result = {
|
|
51
|
+
type: 'HtmlFilteringRuleBody',
|
|
52
|
+
selectorList: SelectorListParser.parse(raw, options, baseOffset),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
result = {
|
|
57
|
+
type: 'Value',
|
|
58
|
+
value: raw,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Include body locations if needed
|
|
62
|
+
if (options.isLocIncluded) {
|
|
63
|
+
result.start = baseOffset;
|
|
64
|
+
result.end = baseOffset + raw.length;
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { HtmlFilteringBodyParser };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
|
+
*/
|
|
7
|
+
import { TokenType, getFormattedTokenName } from '@adguard/css-tokenizer';
|
|
8
|
+
import { sprintf } from 'sprintf-js';
|
|
9
|
+
import { BaseParser } from '../../base-parser.js';
|
|
10
|
+
import { CssTokenStream } from '../../css/css-token-stream.js';
|
|
11
|
+
import { defaultParserOptions } from '../../options.js';
|
|
12
|
+
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
13
|
+
import { ValueParser } from '../../misc/value-parser.js';
|
|
14
|
+
import { UBO_RESPONSEHEADER_FN } from '../../../utils/constants.js';
|
|
15
|
+
import { HtmlFilteringBodyParser } from './html-filtering-body-parser.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `UboHtmlFilteringBodyParser` is responsible for parsing the body of
|
|
19
|
+
* an uBlock-style HTML filtering rule, and also uBlock-style response header removal rule.
|
|
20
|
+
*
|
|
21
|
+
* Please note that the parser will parse any HTML filtering rule if it is syntactically correct.
|
|
22
|
+
* For example, it will parse this:
|
|
23
|
+
* ```adblock
|
|
24
|
+
* example.com##^script:pseudo(content)
|
|
25
|
+
* example.com##^responseheader(header-name)
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* but it didn't check if the pseudo selector `pseudo` or if
|
|
29
|
+
* the header name `header-name` actually supported by any adblocker.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
32
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#html-filters}
|
|
33
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#response-header-filtering}
|
|
34
|
+
*/
|
|
35
|
+
class UboHtmlFilteringBodyParser extends BaseParser {
|
|
36
|
+
/**
|
|
37
|
+
* Parses the body of an uBlock-style HTML filtering rule
|
|
38
|
+
* and also uBlock-style response header removal rule.
|
|
39
|
+
*
|
|
40
|
+
* @param raw Raw input to parse.
|
|
41
|
+
* @param options Global parser options.
|
|
42
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
43
|
+
*
|
|
44
|
+
* @returns Node of the parsed HTML filtering rule body.
|
|
45
|
+
*
|
|
46
|
+
* @throws If the body is syntactically incorrect.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```
|
|
50
|
+
* div:has-text(Example)
|
|
51
|
+
* responseheader(header-name)
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
55
|
+
// First, check if it's a response header removal rule and return if so
|
|
56
|
+
const responseHeaderBody = UboHtmlFilteringBodyParser.parseResponseHeaderRule(raw, options, baseOffset);
|
|
57
|
+
if (responseHeaderBody !== null) {
|
|
58
|
+
return responseHeaderBody;
|
|
59
|
+
}
|
|
60
|
+
return HtmlFilteringBodyParser.parse(raw, options, baseOffset);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parses uBlock-style response header removal rule body.
|
|
64
|
+
*
|
|
65
|
+
* @param raw Raw input to parse.
|
|
66
|
+
* @param options Global parser options.
|
|
67
|
+
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
68
|
+
*
|
|
69
|
+
* @returns Node of the parsed response header removal rule body
|
|
70
|
+
* or `null` if the body is not a response header removal rule.
|
|
71
|
+
*
|
|
72
|
+
* @throws If the body is syntactically incorrect.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```
|
|
76
|
+
* responseheader(header-name)
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @note This method returns `HtmlFilteringRuleBody` because,
|
|
80
|
+
* response header removal rule syntax is same as uBlock-style
|
|
81
|
+
* HTML filtering rule syntax.
|
|
82
|
+
*/
|
|
83
|
+
static parseResponseHeaderRule(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
84
|
+
// If HTML filtering rules parsing is disabled, return null
|
|
85
|
+
if (!options.parseHtmlFilteringRuleBodies) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
// Construct the stream
|
|
89
|
+
const stream = new CssTokenStream(raw, baseOffset);
|
|
90
|
+
// Skip whitespaces before function
|
|
91
|
+
stream.skipWhitespace();
|
|
92
|
+
// Get token
|
|
93
|
+
let token = stream.get();
|
|
94
|
+
// Token should be a function
|
|
95
|
+
if (!token || token.type !== TokenType.Function) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
// Save the function start position
|
|
99
|
+
const { start } = token;
|
|
100
|
+
// Extract function name raw value (without opening parenthesis)
|
|
101
|
+
const functionNameRaw = raw.slice(token.start, token.end - 1);
|
|
102
|
+
// Check if it's `responseheader` function
|
|
103
|
+
if (functionNameRaw !== UBO_RESPONSEHEADER_FN) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
// Advance function token
|
|
107
|
+
stream.advance();
|
|
108
|
+
// Skip whitespaces after opening parenthesis
|
|
109
|
+
stream.skipWhitespace();
|
|
110
|
+
// Get argument token
|
|
111
|
+
token = stream.getOrFail();
|
|
112
|
+
// Save argument start position (starts after opening parenthesis and whitespaces)
|
|
113
|
+
const argumentStart = token.start;
|
|
114
|
+
// Skip until balanced (search for closing parenthesis)
|
|
115
|
+
stream.skipUntilBalanced();
|
|
116
|
+
// Get closing parenthesis token
|
|
117
|
+
token = stream.getOrFail();
|
|
118
|
+
// Save argument end position (ends before closing parenthesis)
|
|
119
|
+
const argumentEnd = token.start;
|
|
120
|
+
// Extract argument raw value
|
|
121
|
+
const argumentRaw = raw.slice(argumentStart, argumentEnd).trimEnd();
|
|
122
|
+
// Throw if the argument is empty
|
|
123
|
+
if (argumentRaw.length === 0) {
|
|
124
|
+
throw new AdblockSyntaxError(`Empty parameter for '${UBO_RESPONSEHEADER_FN}' function`, argumentStart + baseOffset, argumentEnd + baseOffset);
|
|
125
|
+
}
|
|
126
|
+
// Expect closing parenthesis
|
|
127
|
+
stream.expect(TokenType.CloseParenthesis);
|
|
128
|
+
// Advance closing parenthesis token
|
|
129
|
+
stream.advance();
|
|
130
|
+
// Skip whitespaces after closing parenthesis
|
|
131
|
+
stream.skipWhitespace();
|
|
132
|
+
// Expect the end of the rule - so nothing should be left in the stream
|
|
133
|
+
if (!stream.isEof()) {
|
|
134
|
+
token = stream.getOrFail();
|
|
135
|
+
throw new AdblockSyntaxError(sprintf("Expected end of rule, but got '%s'", getFormattedTokenName(token.type)), token.start + baseOffset, token.end + baseOffset);
|
|
136
|
+
}
|
|
137
|
+
// Construct pseudo-class selector node
|
|
138
|
+
const pseudoClassSelectorNode = {
|
|
139
|
+
type: 'PseudoClassSelector',
|
|
140
|
+
name: ValueParser.parse(functionNameRaw, options, start + baseOffset),
|
|
141
|
+
argument: ValueParser.parse(argumentRaw, options, argumentStart + baseOffset),
|
|
142
|
+
};
|
|
143
|
+
// Construct complex selector node
|
|
144
|
+
const complexSelectorNode = {
|
|
145
|
+
type: 'ComplexSelector',
|
|
146
|
+
children: [pseudoClassSelectorNode],
|
|
147
|
+
};
|
|
148
|
+
// Construct selector list node
|
|
149
|
+
const selectorList = {
|
|
150
|
+
type: 'SelectorList',
|
|
151
|
+
children: [complexSelectorNode],
|
|
152
|
+
};
|
|
153
|
+
// Construct body node
|
|
154
|
+
const result = {
|
|
155
|
+
type: 'HtmlFilteringRuleBody',
|
|
156
|
+
selectorList,
|
|
157
|
+
};
|
|
158
|
+
// Get last non-whitespace token
|
|
159
|
+
const lastNonWsToken = stream.lookbehindForNonWs();
|
|
160
|
+
// It shouldn't be null here, but just to be safe if it is
|
|
161
|
+
// it means that raw is empty or contains only whitespaces
|
|
162
|
+
if (!lastNonWsToken) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
// Include locations info if needed
|
|
166
|
+
if (options.isLocIncluded) {
|
|
167
|
+
result.start = baseOffset;
|
|
168
|
+
result.end = raw.length + baseOffset;
|
|
169
|
+
selectorList.start = start + baseOffset;
|
|
170
|
+
selectorList.end = lastNonWsToken.end + baseOffset;
|
|
171
|
+
complexSelectorNode.start = selectorList.start;
|
|
172
|
+
complexSelectorNode.end = selectorList.end;
|
|
173
|
+
pseudoClassSelectorNode.start = complexSelectorNode.start;
|
|
174
|
+
pseudoClassSelectorNode.end = complexSelectorNode.end;
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { UboHtmlFilteringBodyParser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree
|
|
3
|
-
* (c)
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
|
+
*/
|
|
7
|
+
import { TokenType, getFormattedTokenName } from '@adguard/css-tokenizer';
|
|
8
|
+
import { sprintf } from 'sprintf-js';
|
|
9
|
+
import { AdblockSyntaxError } from '../../../../errors/adblock-syntax-error.js';
|
|
10
|
+
import { TILDE, CARET, DOLLAR_SIGN, ASTERISK, PIPE, EQUALS } from '../../../../utils/constants.js';
|
|
11
|
+
import { QuoteUtils } from '../../../../utils/quotes.js';
|
|
12
|
+
import { ValueParser } from '../../../misc/value-parser.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Handles attribute selector parsing in selector list.
|
|
16
|
+
*/
|
|
17
|
+
class AttributeSelectorHandler {
|
|
18
|
+
/**
|
|
19
|
+
* Set of attribute equality prefixes.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link AttributeSelectorOperatorValue}
|
|
22
|
+
*/
|
|
23
|
+
static ATTR_EQUALITY_PREFIXES = new Set([
|
|
24
|
+
// [attr~="value"]
|
|
25
|
+
TILDE,
|
|
26
|
+
// [attr^="value"]
|
|
27
|
+
CARET,
|
|
28
|
+
// [attr$="value"]
|
|
29
|
+
DOLLAR_SIGN,
|
|
30
|
+
// [attr*="value"]
|
|
31
|
+
ASTERISK,
|
|
32
|
+
// [attr|="value"]
|
|
33
|
+
PIPE,
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* Set of valid flags for attribute selector values.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link AttributeSelectorFlagValue}
|
|
39
|
+
*/
|
|
40
|
+
static ALLOWED_ATTRIBUTE_FLAGS = new Set([
|
|
41
|
+
'i',
|
|
42
|
+
's',
|
|
43
|
+
]);
|
|
44
|
+
/**
|
|
45
|
+
* Handles attribute selector parsing by creating an attribute selector node
|
|
46
|
+
* and appending it to the current complex selector node.
|
|
47
|
+
*
|
|
48
|
+
* @param context Selector list parser context.
|
|
49
|
+
*
|
|
50
|
+
* @throws If the attribute selector is syntactically incorrect.
|
|
51
|
+
*/
|
|
52
|
+
static handle(context) {
|
|
53
|
+
const { options, baseOffset, stream, complexSelector, } = context;
|
|
54
|
+
// Get open square bracket token
|
|
55
|
+
let token = stream.getOrFail();
|
|
56
|
+
// Save attribute selector node start position
|
|
57
|
+
const { start } = token;
|
|
58
|
+
// Advance open square bracket token
|
|
59
|
+
stream.advance();
|
|
60
|
+
// Skip whitespaces after open square bracket
|
|
61
|
+
stream.skipWhitespace();
|
|
62
|
+
// Expect next token to be an identifier (attribute selector name)
|
|
63
|
+
stream.expect(TokenType.Ident);
|
|
64
|
+
// Get attribute selector name token
|
|
65
|
+
token = stream.getOrFail();
|
|
66
|
+
// Extract attribute selector name raw value
|
|
67
|
+
const nameRaw = stream.fragment();
|
|
68
|
+
// Construct attribute selector node and attribute selector name node
|
|
69
|
+
const result = {
|
|
70
|
+
type: 'AttributeSelector',
|
|
71
|
+
name: ValueParser.parse(nameRaw, options, baseOffset + token.start),
|
|
72
|
+
};
|
|
73
|
+
// Include attribute selector node start location if needed
|
|
74
|
+
if (options.isLocIncluded) {
|
|
75
|
+
result.start = baseOffset + start;
|
|
76
|
+
}
|
|
77
|
+
// Advance attribute selector name token
|
|
78
|
+
stream.advance();
|
|
79
|
+
// Skip whitespaces after attribute selector name
|
|
80
|
+
stream.skipWhitespace();
|
|
81
|
+
// Get closing square bracket or equality sign/prefix token
|
|
82
|
+
token = stream.getOrFail();
|
|
83
|
+
// Check if there is an any value
|
|
84
|
+
if (token.type !== TokenType.CloseSquareBracket) {
|
|
85
|
+
// Expect next token to be a delimiter (equality sign/prefix)
|
|
86
|
+
stream.expect(TokenType.Delim);
|
|
87
|
+
// Extract operator raw value
|
|
88
|
+
let operatorRaw = stream.fragment();
|
|
89
|
+
// Check if it's prefix operator
|
|
90
|
+
if (AttributeSelectorHandler.ATTR_EQUALITY_PREFIXES.has(operatorRaw)) {
|
|
91
|
+
// Advance prefix operator token
|
|
92
|
+
stream.advance();
|
|
93
|
+
// Expect equal sign token
|
|
94
|
+
stream.expect(TokenType.Delim, { value: EQUALS });
|
|
95
|
+
// Append equal sign to prefix value
|
|
96
|
+
operatorRaw += EQUALS;
|
|
97
|
+
}
|
|
98
|
+
else if (operatorRaw !== EQUALS) {
|
|
99
|
+
// Throw error if it's not equal sign either
|
|
100
|
+
throw new AdblockSyntaxError(sprintf("Invalid attribute selector operator '%s'", operatorRaw), baseOffset + token.start, baseOffset + token.end);
|
|
101
|
+
}
|
|
102
|
+
// Save operator node start position
|
|
103
|
+
const operatorStart = token.start;
|
|
104
|
+
// Advance equal sign token
|
|
105
|
+
stream.advance();
|
|
106
|
+
// Skip whitespaces after equal sign
|
|
107
|
+
stream.skipWhitespace();
|
|
108
|
+
// Get attribute selector value token
|
|
109
|
+
token = stream.getOrFail();
|
|
110
|
+
// It should be a string or identifier
|
|
111
|
+
const isValueString = token.type === TokenType.String;
|
|
112
|
+
if (!isValueString && token.type !== TokenType.Ident) {
|
|
113
|
+
throw new AdblockSyntaxError(sprintf(
|
|
114
|
+
// eslint-disable-next-line max-len
|
|
115
|
+
`Expected '${getFormattedTokenName(TokenType.Ident)}' or '${getFormattedTokenName(TokenType.String)}' as attribute selector value, but got '%s' with value '%s'`, getFormattedTokenName(token.type), stream.fragment()), baseOffset + token.start, baseOffset + token.end);
|
|
116
|
+
}
|
|
117
|
+
// Save attribute selector value node start position
|
|
118
|
+
const valueStart = token.start + (isValueString ? 1 : 0);
|
|
119
|
+
// Save attribute selector value node end position
|
|
120
|
+
const valueEnd = token.end - (isValueString ? 1 : 0);
|
|
121
|
+
// Extract attribute selector value raw value
|
|
122
|
+
const valueRaw = stream.fragment();
|
|
123
|
+
// We should unescape respective quotes inside of the string value
|
|
124
|
+
const valueUnquotedAndUnescaped = QuoteUtils.removeQuotesAndUnescape(valueRaw);
|
|
125
|
+
// Construct attribute selector operator node
|
|
126
|
+
const operatorNode = {
|
|
127
|
+
type: 'Value',
|
|
128
|
+
value: operatorRaw,
|
|
129
|
+
};
|
|
130
|
+
// Construct attribute selector value node
|
|
131
|
+
const valueNode = {
|
|
132
|
+
type: 'Value',
|
|
133
|
+
value: valueUnquotedAndUnescaped,
|
|
134
|
+
};
|
|
135
|
+
// Set attribute selector operator and value nodes to result node
|
|
136
|
+
result.operator = operatorNode;
|
|
137
|
+
result.value = valueNode;
|
|
138
|
+
// Include attribute selector operator and value nodes locations if needed
|
|
139
|
+
if (options.isLocIncluded) {
|
|
140
|
+
operatorNode.start = baseOffset + operatorStart;
|
|
141
|
+
operatorNode.end = baseOffset + operatorStart + operatorRaw.length;
|
|
142
|
+
valueNode.start = baseOffset + valueStart;
|
|
143
|
+
valueNode.end = baseOffset + valueEnd;
|
|
144
|
+
}
|
|
145
|
+
// Advance attribute selector value token
|
|
146
|
+
stream.advance();
|
|
147
|
+
// Skip whitespaces after attribute selector value
|
|
148
|
+
stream.skipWhitespace();
|
|
149
|
+
// Get close square bracket or attribute selector value flag token
|
|
150
|
+
token = stream.getOrFail();
|
|
151
|
+
// Check if there is an any flag part
|
|
152
|
+
if (token.type !== TokenType.CloseSquareBracket) {
|
|
153
|
+
// Expect a identifier (attribute selector value flag)
|
|
154
|
+
stream.expect(TokenType.Ident);
|
|
155
|
+
// Extract attribute selector value flag raw value
|
|
156
|
+
const flagRaw = stream.fragment();
|
|
157
|
+
// Validate attribute selector value flag
|
|
158
|
+
if (!AttributeSelectorHandler.isValidFlag(flagRaw)) {
|
|
159
|
+
throw new AdblockSyntaxError(sprintf("Unexpected token '%s' with value '%s'", getFormattedTokenName(token.type), flagRaw), baseOffset + token.start, baseOffset + token.end);
|
|
160
|
+
}
|
|
161
|
+
// Save flag node start position
|
|
162
|
+
const flagStart = token.start;
|
|
163
|
+
// Construct attribute selector flag node
|
|
164
|
+
const flagNode = {
|
|
165
|
+
type: 'Value',
|
|
166
|
+
value: flagRaw,
|
|
167
|
+
};
|
|
168
|
+
// Set attribute selector flag node to result node
|
|
169
|
+
result.flag = flagNode;
|
|
170
|
+
// Include attribute selector flag node locations if needed
|
|
171
|
+
if (options.isLocIncluded) {
|
|
172
|
+
flagNode.start = baseOffset + flagStart;
|
|
173
|
+
flagNode.end = baseOffset + flagStart + flagRaw.length;
|
|
174
|
+
}
|
|
175
|
+
// Advance attribute selector value flag token
|
|
176
|
+
stream.advance();
|
|
177
|
+
// Skip whitespaces after attribute selector value flag
|
|
178
|
+
stream.skipWhitespace();
|
|
179
|
+
// Get close square bracket token
|
|
180
|
+
token = stream.getOrFail();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Expect close square bracket token
|
|
184
|
+
stream.expect(TokenType.CloseSquareBracket);
|
|
185
|
+
// Include attribute selector node end location if needed
|
|
186
|
+
if (options.isLocIncluded) {
|
|
187
|
+
result.end = baseOffset + token.end;
|
|
188
|
+
}
|
|
189
|
+
// Append attribute selector node to the current complex selector node
|
|
190
|
+
complexSelector.children.push(result);
|
|
191
|
+
// Advance close square bracket token
|
|
192
|
+
stream.advance();
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Validates attribute selector flag.
|
|
196
|
+
*
|
|
197
|
+
* @param flag Attribute selector flag.
|
|
198
|
+
*
|
|
199
|
+
* @returns `true` if the flag is valid, otherwise `false`.
|
|
200
|
+
*/
|
|
201
|
+
static isValidFlag(flag) {
|
|
202
|
+
return AttributeSelectorHandler.ALLOWED_ATTRIBUTE_FLAGS.has(flag);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { AttributeSelectorHandler };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
+
* (c) 2026 Adguard Software Ltd.
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
|
+
*/
|
|
7
|
+
import { TokenType } from '@adguard/css-tokenizer';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Handles class selector parsing in selector list.
|
|
11
|
+
*/
|
|
12
|
+
class ClassSelectorHandler {
|
|
13
|
+
/**
|
|
14
|
+
* Handles class selector parsing by creating a class selector node
|
|
15
|
+
* and appending it to the current complex selector node.
|
|
16
|
+
*
|
|
17
|
+
* @param context Selector list parser context.
|
|
18
|
+
*
|
|
19
|
+
* @throws If the class selector is syntactically incorrect.
|
|
20
|
+
*/
|
|
21
|
+
static handle(context) {
|
|
22
|
+
const { options, baseOffset, stream, complexSelector, } = context;
|
|
23
|
+
// Get class selector dot token
|
|
24
|
+
const token = stream.getOrFail();
|
|
25
|
+
// Advance class selector dot token
|
|
26
|
+
stream.advance();
|
|
27
|
+
// Expect next token to be an identifier (class selector value)
|
|
28
|
+
stream.expect(TokenType.Ident);
|
|
29
|
+
// Extract class selector value (without dot)
|
|
30
|
+
const value = stream.fragment();
|
|
31
|
+
// Construct class selector node
|
|
32
|
+
const result = {
|
|
33
|
+
type: 'ClassSelector',
|
|
34
|
+
value,
|
|
35
|
+
};
|
|
36
|
+
// Include class selector node locations if needed
|
|
37
|
+
if (options.isLocIncluded) {
|
|
38
|
+
result.start = baseOffset + token.start;
|
|
39
|
+
result.end = baseOffset + token.end + value.length;
|
|
40
|
+
}
|
|
41
|
+
// Append class selector node to the current complex selector node
|
|
42
|
+
complexSelector.children.push(result);
|
|
43
|
+
// Advance class selector value token
|
|
44
|
+
stream.advance();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { ClassSelectorHandler };
|