re2 1.25.0 → 1.25.1

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/README.md CHANGED
@@ -251,13 +251,7 @@ See the wiki for notes on [yarn](https://github.com/uhop/node-re2/wiki/Using-wit
251
251
 
252
252
  ### Supported Node.js versions
253
253
 
254
- `re2` supports the Node.js versions declared in its `engines` field:
255
-
256
- ```
257
- ^22.22.2 || ^24.15.0 || >=26.0.0
258
- ```
259
-
260
- As of 1.25.0 this range was narrowed to mirror [`node-gyp`](https://github.com/nodejs/node-gyp) 13, which `re2` builds with (and which fixes a Node 26 build on Windows): **Node 25.x and the older 22.0–22.22.1 / 24.0–24.14 patch ranges are no longer supported.** Use a current release of an active line — Node 22 (≥ 22.22.2), 24 (≥ 24.15.0), or 26 and later.
254
+ `re2` supports every non-EOL Node.js release — current and active LTS lines. As a native (`nan`) addon it runs on Node.js only, not Bun or Deno. The authoritative supported range is the `engines` field in `package.json`; it also pins the minimum patch releases the build toolchain ([`node-gyp`](https://github.com/nodejs/node-gyp) 13) requires. Check `engines` for the exact floor rather than a version repeated here.
261
255
 
262
256
  ### Install scripts (npm 12+)
263
257
 
@@ -442,6 +436,7 @@ Tables are baked in at build time from Unicode 17.0. To target a newer Unicode v
442
436
 
443
437
  ## Release history
444
438
 
439
+ - 1.25.1 *Security fix (GHSA-8hcv-x26h-mcgp): a global `replace()` using an output-amplifying template (`$'` or `` $` ``) on very large input could exceed V8's maximum string length and abort the whole process. It now throws a catchable `RangeError`, matching the built-in engine.*
445
440
  - 1.25.0 *Full Unicode 17.0.0 property classes (Fixes #226). New `maxMem` option for `RE2.Set`. Faster matching on pure-ASCII inputs. Narrowed Node support — drops Node 25.x and older patch releases.*
446
441
  - 1.24.1 *Support for Node 22, 24, 26 + precompiled binaries.*
447
442
  - 1.24.0 *Fixed multi-threaded crash in worker threads (#235). Added named import: `import {RE2} from 're2'`. Added CJS test. Updated docs and dependencies.*
package/lib/replace.cc CHANGED
@@ -315,7 +315,13 @@ inline Nan::Maybe<std::string> replace(
315
315
  const auto data = item.data();
316
316
  if (data)
317
317
  {
318
- argv.push_back(Nan::CopyBuffer(data, item.size()).ToLocalChecked());
318
+ auto buffer = Nan::CopyBuffer(data, item.size());
319
+ if (buffer.IsEmpty())
320
+ {
321
+ Nan::ThrowRangeError("Invalid string length");
322
+ return Nan::Nothing<std::string>();
323
+ }
324
+ argv.push_back(buffer.ToLocalChecked());
319
325
  }
320
326
  else
321
327
  {
@@ -332,7 +338,13 @@ inline Nan::Maybe<std::string> replace(
332
338
  const auto data = item.data();
333
339
  if (data)
334
340
  {
335
- argv.push_back(Nan::New(data, item.size()).ToLocalChecked());
341
+ auto text = Nan::New(data, item.size());
342
+ if (text.IsEmpty())
343
+ {
344
+ Nan::ThrowRangeError("Invalid string length");
345
+ return Nan::Nothing<std::string>();
346
+ }
347
+ argv.push_back(text.ToLocalChecked());
336
348
  }
337
349
  else
338
350
  {
@@ -551,8 +563,21 @@ NAN_METHOD(WrappedRE2::Replace)
551
563
 
552
564
  if (replacee.isBuffer)
553
565
  {
554
- info.GetReturnValue().Set(Nan::CopyBuffer(result.data(), result.size()).ToLocalChecked());
566
+ auto buffer = Nan::CopyBuffer(result.data(), result.size());
567
+ if (buffer.IsEmpty())
568
+ {
569
+ Nan::ThrowRangeError("Invalid string length");
570
+ return;
571
+ }
572
+ info.GetReturnValue().Set(buffer.ToLocalChecked());
573
+ return;
574
+ }
575
+ // over-max-length result -> empty MaybeLocal; ToLocalChecked() would abort()
576
+ auto text = Nan::New(result);
577
+ if (text.IsEmpty())
578
+ {
579
+ Nan::ThrowRangeError("Invalid string length");
555
580
  return;
556
581
  }
557
- info.GetReturnValue().Set(Nan::New(result).ToLocalChecked());
582
+ info.GetReturnValue().Set(text.ToLocalChecked());
558
583
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "re2",
3
- "version": "1.25.0",
3
+ "version": "1.25.1",
4
4
  "description": "Bindings for RE2: fast, safe alternative to backtracking regular expression engines.",
5
5
  "homepage": "https://github.com/uhop/node-re2",
6
6
  "bugs": "https://github.com/uhop/node-re2/issues",
@@ -22,11 +22,11 @@
22
22
  "node-gyp": "^13.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "^25.9.3",
25
+ "@types/node": "^26.0.1",
26
26
  "@unicode/unicode-17.0.0": "^1.6.17",
27
27
  "nano-benchmark": "^1.0.16",
28
28
  "prettier": "^3.8.4",
29
- "tape-six": "^1.10.1",
29
+ "tape-six": "^1.14.0",
30
30
  "tape-six-proc": "^1.3.1",
31
31
  "typescript": "^6.0.3"
32
32
  },
@@ -65,8 +65,6 @@
65
65
  ],
66
66
  "author": "Eugene Lazutkin <eugene.lazutkin@gmail.com> (https://lazutkin.com/)",
67
67
  "funding": "https://github.com/sponsors/uhop",
68
- "llms": "https://raw.githubusercontent.com/uhop/node-re2/master/llms.txt",
69
- "llmsFull": "https://raw.githubusercontent.com/uhop/node-re2/master/llms-full.txt",
70
68
  "license": "BSD-3-Clause",
71
69
  "tape6": {
72
70
  "tests": [