@adguard/agtree 1.1.1 → 1.1.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog][keepachangelog], and this project adheres to [Semantic Versioning][semver].
6
6
 
7
+ ## 1.1.2 - 2023-08-14
8
+
9
+ ### Fixed
10
+
11
+ - Compatibility tables validation of ABP syntax `$rewrite`
12
+ - Detecting closing parenthesis in ADG/uBO scriptlets while parsing
13
+
7
14
  ## 1.1.1 - 2023-08-11
8
15
 
9
16
  ### Fixed
package/dist/agtree.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v1.1.1 (build date: Fri, 11 Aug 2023 13:11:01 GMT)
2
+ * AGTree v1.1.2 (build date: Mon, 14 Aug 2023 13:52:06 GMT)
3
3
  * (c) 2023 AdGuard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -4327,21 +4327,15 @@ class ScriptletInjectionBodyParser {
4327
4327
  }
4328
4328
  // Save the offset of the opening parentheses
4329
4329
  const openingParenthesesIndex = offset;
4330
- // Find closing parentheses
4331
- // eslint-disable-next-line max-len
4332
- const closingParenthesesIndex = StringUtils.findUnescapedNonStringNonRegexChar(raw, CLOSE_PARENTHESIS, openingParenthesesIndex + 1);
4330
+ // Skip whitespace from the end
4331
+ const closingParenthesesIndex = StringUtils.skipWSBack(raw, raw.length - 1);
4333
4332
  // Closing parentheses should be present
4334
- if (closingParenthesesIndex === -1) {
4333
+ if (raw[closingParenthesesIndex] !== CLOSE_PARENTHESIS
4334
+ || raw[closingParenthesesIndex - 1] === ESCAPE_CHARACTER) {
4335
4335
  throw new AdblockSyntaxError(
4336
4336
  // eslint-disable-next-line max-len
4337
4337
  `Invalid AdGuard/uBlock scriptlet call, no closing parentheses '${CLOSE_PARENTHESIS}' found`, locRange(loc, offset, raw.length));
4338
4338
  }
4339
- // Shouldn't have any characters after the closing parentheses
4340
- if (StringUtils.skipWSBack(raw) !== closingParenthesesIndex) {
4341
- throw new AdblockSyntaxError(
4342
- // eslint-disable-next-line max-len
4343
- `Invalid AdGuard/uBlock scriptlet call, unexpected characters after the closing parentheses '${CLOSE_PARENTHESIS}'`, locRange(loc, closingParenthesesIndex + 1, raw.length));
4344
- }
4345
4339
  // Parse parameter list
4346
4340
  const params = ParameterListParser.parse(raw.substring(openingParenthesesIndex + 1, closingParenthesesIndex), COMMA, shiftLoc(loc, openingParenthesesIndex + 1));
4347
4341
  // Allow empty scritptlet call: js() or //scriptlet(), but not allow parameters
@@ -6539,7 +6533,13 @@ var data$g = { adg_os_any:{ name:"redirect",
6539
6533
  assignable:true,
6540
6534
  negatable:false,
6541
6535
  value_optional:true,
6542
- value_format:"(?x)\n ^(\n 1x1\\.gif|\n 2x2\\.png|\n 3x2\\.png|\n 32x32\\.png|\n noop\\.css|\n noop\\.html|\n noopframe|\n noop\\.js|\n noop\\.txt|\n noop-0\\.1s\\.mp3|\n noop-0\\.5s\\.mp3|\n noop-1s\\.mp4|\n none|\n click2load\\.html|\n addthis_widget\\.js|\n amazon_ads\\.js|\n amazon_apstag\\.js|\n monkeybroker\\.js|\n doubleclick_instream_ad_status|\n google-analytics_ga\\.js|\n google-analytics_analytics\\.js|\n google-analytics_inpage_linkid\\.js|\n google-analytics_cx_api\\.js|\n google-ima\\.js|\n googletagservices_gpt\\.js|\n googletagmanager_gtm\\.js|\n googlesyndication_adsbygoogle\\.js|\n scorecardresearch_beacon\\.js|\n outbrain-widget\\.js|\n hd-main\\.js\n )\n (:[0-9]+)?$" } };
6536
+ value_format:"(?x)\n ^(\n 1x1\\.gif|\n 2x2\\.png|\n 3x2\\.png|\n 32x32\\.png|\n noop\\.css|\n noop\\.html|\n noopframe|\n noop\\.js|\n noop\\.txt|\n noop-0\\.1s\\.mp3|\n noop-0\\.5s\\.mp3|\n noop-1s\\.mp4|\n none|\n click2load\\.html|\n addthis_widget\\.js|\n amazon_ads\\.js|\n amazon_apstag\\.js|\n monkeybroker\\.js|\n doubleclick_instream_ad_status|\n google-analytics_ga\\.js|\n google-analytics_analytics\\.js|\n google-analytics_inpage_linkid\\.js|\n google-analytics_cx_api\\.js|\n google-ima\\.js|\n googletagservices_gpt\\.js|\n googletagmanager_gtm\\.js|\n googlesyndication_adsbygoogle\\.js|\n scorecardresearch_beacon\\.js|\n outbrain-widget\\.js|\n hd-main\\.js\n )\n (:[0-9]+)?$" },
6537
+ abp_ext_any:{ name:"rewrite",
6538
+ description:"The `rewrite=` option allows the rewriting of URLs (or redirecting requests) to an internal\nresource in order to deactivate it without causing an error. Indicate the internal resource\nby name and prefix `abp-resource:` in order to be recognized. For example\n`$rewrite=abp-resource:blank-js` sends an empty JavaScript.",
6539
+ docs:"https://help.adblockplus.org/hc/en-us/articles/360062733293#rewrite",
6540
+ assignable:true,
6541
+ negatable:false,
6542
+ value_format:"(?x)\n # ABP resources always starts with the `abp-resource:` prefix\n ^abp-resource:\n # Possible resource names\n (\n blank-text|\n blank-css|\n blank-js|\n blank-html|\n blank-mp3|\n 1x1-transparent-gif|\n 2x2-transparent-png|\n 3x2-transparent-png|\n 32x32-transparent-png\n )$" } };
6543
6543
 
6544
6544
  var data$f = { adg_os_any:{ name:"removeheader",
6545
6545
  description:"Rules with the `$removeheader` modifier are intended to remove headers from HTTP requests and responses.",
@@ -8894,7 +8894,7 @@ class LogicalExpressionUtils {
8894
8894
  }
8895
8895
  }
8896
8896
 
8897
- const version$1 = "1.1.1";
8897
+ const version$1 = "1.1.2";
8898
8898
 
8899
8899
  /**
8900
8900
  * @file AGTree version
package/dist/agtree.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v1.1.1 (build date: Fri, 11 Aug 2023 13:11:01 GMT)
2
+ * AGTree v1.1.2 (build date: Mon, 14 Aug 2023 13:52:06 GMT)
3
3
  * (c) 2023 AdGuard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v1.1.1 (build date: Fri, 11 Aug 2023 13:11:01 GMT)
2
+ * AGTree v1.1.2 (build date: Mon, 14 Aug 2023 13:52:06 GMT)
3
3
  * (c) 2023 AdGuard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -4308,21 +4308,15 @@ class ScriptletInjectionBodyParser {
4308
4308
  }
4309
4309
  // Save the offset of the opening parentheses
4310
4310
  const openingParenthesesIndex = offset;
4311
- // Find closing parentheses
4312
- // eslint-disable-next-line max-len
4313
- const closingParenthesesIndex = StringUtils.findUnescapedNonStringNonRegexChar(raw, CLOSE_PARENTHESIS, openingParenthesesIndex + 1);
4311
+ // Skip whitespace from the end
4312
+ const closingParenthesesIndex = StringUtils.skipWSBack(raw, raw.length - 1);
4314
4313
  // Closing parentheses should be present
4315
- if (closingParenthesesIndex === -1) {
4314
+ if (raw[closingParenthesesIndex] !== CLOSE_PARENTHESIS
4315
+ || raw[closingParenthesesIndex - 1] === ESCAPE_CHARACTER) {
4316
4316
  throw new AdblockSyntaxError(
4317
4317
  // eslint-disable-next-line max-len
4318
4318
  `Invalid AdGuard/uBlock scriptlet call, no closing parentheses '${CLOSE_PARENTHESIS}' found`, locRange(loc, offset, raw.length));
4319
4319
  }
4320
- // Shouldn't have any characters after the closing parentheses
4321
- if (StringUtils.skipWSBack(raw) !== closingParenthesesIndex) {
4322
- throw new AdblockSyntaxError(
4323
- // eslint-disable-next-line max-len
4324
- `Invalid AdGuard/uBlock scriptlet call, unexpected characters after the closing parentheses '${CLOSE_PARENTHESIS}'`, locRange(loc, closingParenthesesIndex + 1, raw.length));
4325
- }
4326
4320
  // Parse parameter list
4327
4321
  const params = ParameterListParser.parse(raw.substring(openingParenthesesIndex + 1, closingParenthesesIndex), COMMA, shiftLoc(loc, openingParenthesesIndex + 1));
4328
4322
  // Allow empty scritptlet call: js() or //scriptlet(), but not allow parameters
@@ -6520,7 +6514,13 @@ var data$g = { adg_os_any:{ name:"redirect",
6520
6514
  assignable:true,
6521
6515
  negatable:false,
6522
6516
  value_optional:true,
6523
- value_format:"(?x)\n ^(\n 1x1\\.gif|\n 2x2\\.png|\n 3x2\\.png|\n 32x32\\.png|\n noop\\.css|\n noop\\.html|\n noopframe|\n noop\\.js|\n noop\\.txt|\n noop-0\\.1s\\.mp3|\n noop-0\\.5s\\.mp3|\n noop-1s\\.mp4|\n none|\n click2load\\.html|\n addthis_widget\\.js|\n amazon_ads\\.js|\n amazon_apstag\\.js|\n monkeybroker\\.js|\n doubleclick_instream_ad_status|\n google-analytics_ga\\.js|\n google-analytics_analytics\\.js|\n google-analytics_inpage_linkid\\.js|\n google-analytics_cx_api\\.js|\n google-ima\\.js|\n googletagservices_gpt\\.js|\n googletagmanager_gtm\\.js|\n googlesyndication_adsbygoogle\\.js|\n scorecardresearch_beacon\\.js|\n outbrain-widget\\.js|\n hd-main\\.js\n )\n (:[0-9]+)?$" } };
6517
+ value_format:"(?x)\n ^(\n 1x1\\.gif|\n 2x2\\.png|\n 3x2\\.png|\n 32x32\\.png|\n noop\\.css|\n noop\\.html|\n noopframe|\n noop\\.js|\n noop\\.txt|\n noop-0\\.1s\\.mp3|\n noop-0\\.5s\\.mp3|\n noop-1s\\.mp4|\n none|\n click2load\\.html|\n addthis_widget\\.js|\n amazon_ads\\.js|\n amazon_apstag\\.js|\n monkeybroker\\.js|\n doubleclick_instream_ad_status|\n google-analytics_ga\\.js|\n google-analytics_analytics\\.js|\n google-analytics_inpage_linkid\\.js|\n google-analytics_cx_api\\.js|\n google-ima\\.js|\n googletagservices_gpt\\.js|\n googletagmanager_gtm\\.js|\n googlesyndication_adsbygoogle\\.js|\n scorecardresearch_beacon\\.js|\n outbrain-widget\\.js|\n hd-main\\.js\n )\n (:[0-9]+)?$" },
6518
+ abp_ext_any:{ name:"rewrite",
6519
+ description:"The `rewrite=` option allows the rewriting of URLs (or redirecting requests) to an internal\nresource in order to deactivate it without causing an error. Indicate the internal resource\nby name and prefix `abp-resource:` in order to be recognized. For example\n`$rewrite=abp-resource:blank-js` sends an empty JavaScript.",
6520
+ docs:"https://help.adblockplus.org/hc/en-us/articles/360062733293#rewrite",
6521
+ assignable:true,
6522
+ negatable:false,
6523
+ value_format:"(?x)\n # ABP resources always starts with the `abp-resource:` prefix\n ^abp-resource:\n # Possible resource names\n (\n blank-text|\n blank-css|\n blank-js|\n blank-html|\n blank-mp3|\n 1x1-transparent-gif|\n 2x2-transparent-png|\n 3x2-transparent-png|\n 32x32-transparent-png\n )$" } };
6524
6524
 
6525
6525
  var data$f = { adg_os_any:{ name:"removeheader",
6526
6526
  description:"Rules with the `$removeheader` modifier are intended to remove headers from HTTP requests and responses.",
@@ -8875,7 +8875,7 @@ class LogicalExpressionUtils {
8875
8875
  }
8876
8876
  }
8877
8877
 
8878
- const version$1 = "1.1.1";
8878
+ const version$1 = "1.1.2";
8879
8879
 
8880
8880
  /**
8881
8881
  * @file AGTree version