re2 1.15.9 → 1.17.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/.github/actions/linux-alpine-node-12/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-14/Dockerfile +1 -1
- package/.github/actions/{linux-alpine-node-15 → linux-alpine-node-16}/Dockerfile +2 -2
- package/.github/actions/linux-alpine-node-16/action.yml +7 -0
- package/.github/actions/{linux-alpine-node-15 → linux-alpine-node-16}/entrypoint.sh +1 -0
- package/.github/actions/{linux-alpine-node-10 → linux-alpine-node-17}/Dockerfile +2 -2
- package/.github/actions/linux-alpine-node-17/action.yml +7 -0
- package/.github/actions/{linux-alpine-node-10 → linux-alpine-node-17}/entrypoint.sh +1 -0
- package/.github/actions/linux-node-12/Dockerfile +5 -4
- package/.github/dependabot.yml +1 -1
- package/.github/workflows/build.yml +19 -40
- package/.github/workflows/tests.yml +1 -1
- package/README.md +11 -35
- package/binding.gyp +2 -2
- package/lib/exec.cc +4 -1
- package/lib/match.cc +4 -1
- package/lib/replace.cc +8 -2
- package/lib/test.cc +4 -1
- package/package.json +6 -6
- package/re2.d.ts +39 -2
- package/tests/test_exec.js +16 -0
- package/tests/test_general.js +6 -0
- package/vendor/README +3 -1
- package/vendor/re2/bitstate.cc +3 -3
- package/vendor/re2/compile.cc +50 -34
- package/vendor/re2/dfa.cc +24 -21
- package/vendor/re2/fuzzing/re2_fuzzer.cc +96 -20
- package/vendor/re2/make_perl_groups.pl +1 -1
- package/vendor/re2/nfa.cc +5 -5
- package/vendor/re2/onepass.cc +2 -2
- package/vendor/re2/parse.cc +41 -22
- package/vendor/re2/perl_groups.cc +34 -34
- package/vendor/re2/prog.cc +188 -4
- package/vendor/re2/prog.h +45 -13
- package/vendor/re2/re2.cc +7 -12
- package/vendor/re2/re2.h +7 -3
- package/vendor/re2/regexp.cc +11 -5
- package/vendor/re2/regexp.h +7 -2
- package/vendor/re2/set.cc +3 -0
- package/vendor/re2/testing/backtrack.cc +3 -3
- package/vendor/re2/testing/compile_test.cc +45 -21
- package/vendor/re2/testing/dfa_test.cc +4 -4
- package/vendor/re2/testing/exhaustive_tester.cc +2 -2
- package/vendor/re2/testing/parse_test.cc +1 -0
- package/vendor/re2/testing/re2_test.cc +31 -16
- package/vendor/re2/testing/regexp_benchmark.cc +108 -121
- package/vendor/re2/testing/required_prefix_test.cc +78 -24
- package/vendor/re2/testing/search_test.cc +2 -0
- package/vendor/re2/testing/tester.cc +9 -9
- package/vendor/re2/tostring.cc +1 -1
- package/vendor/re2/unicode.py +1 -1
- package/vendor/re2/unicode_casefold.cc +25 -11
- package/vendor/re2/unicode_groups.cc +319 -151
- package/vendor/re2/walker-inl.h +3 -2
- package/vendor/util/mutex.h +2 -2
- package/.github/actions/linux-alpine-node-10/action.yml +0 -7
- package/.github/actions/linux-alpine-node-15/action.yml +0 -7
- package/.github/actions/linux-node-10/Dockerfile +0 -14
- package/.github/actions/linux-node-10/action.yml +0 -12
- package/.github/actions/linux-node-10/entrypoint.sh +0 -15
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
FROM centos:centos7
|
|
2
2
|
|
|
3
3
|
RUN yum install -y centos-release-scl && \
|
|
4
|
-
INSTALL_PKGS="devtoolset-7-gcc devtoolset-7-gcc-c++
|
|
4
|
+
INSTALL_PKGS="devtoolset-7-gcc devtoolset-7-gcc-c++ python3 make" && \
|
|
5
5
|
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
|
|
6
6
|
rpm -V $INSTALL_PKGS && \
|
|
7
|
-
yum -y clean all --enablerepo='*'
|
|
8
|
-
|
|
9
|
-
source scl_source enable
|
|
7
|
+
yum -y clean all --enablerepo='*'
|
|
8
|
+
# && \
|
|
9
|
+
# source scl_source enable devtoolset-7 && \
|
|
10
|
+
# source scl_source enable python3
|
|
10
11
|
|
|
11
12
|
ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
|
|
12
13
|
|
package/.github/dependabot.yml
CHANGED
|
@@ -31,7 +31,7 @@ jobs:
|
|
|
31
31
|
strategy:
|
|
32
32
|
matrix:
|
|
33
33
|
os: [windows-latest, macOS-latest]
|
|
34
|
-
node-version: [
|
|
34
|
+
node-version: [12, 14, 16, 17]
|
|
35
35
|
|
|
36
36
|
steps:
|
|
37
37
|
- uses: actions/checkout@v2
|
|
@@ -65,40 +65,15 @@ jobs:
|
|
|
65
65
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
66
66
|
run: npm run save-to-github
|
|
67
67
|
|
|
68
|
-
build-linux-node-10:
|
|
69
|
-
name: Node.js 10 on CentOS 6
|
|
70
|
-
needs: create-release
|
|
71
|
-
runs-on: ubuntu-latest
|
|
72
|
-
|
|
73
|
-
steps:
|
|
74
|
-
- uses: actions/checkout@v2
|
|
75
|
-
with:
|
|
76
|
-
submodules: true
|
|
77
|
-
- name: Get NPM cache directory
|
|
78
|
-
id: npm-cache
|
|
79
|
-
run: |
|
|
80
|
-
echo "::set-output name=dir::$(npm config get cache)"
|
|
81
|
-
- name: Cache node modules
|
|
82
|
-
uses: actions/cache@v2
|
|
83
|
-
with:
|
|
84
|
-
path: ${{steps.npm-cache.outputs.dir}}
|
|
85
|
-
key: Linux-node-${{hashFiles('**/package-lock.json')}}
|
|
86
|
-
restore-keys: |
|
|
87
|
-
Linux-node-
|
|
88
|
-
Linux-
|
|
89
|
-
- name: Install, test, and create artifact
|
|
90
|
-
uses: ./.github/actions/linux-node-10/
|
|
91
|
-
env:
|
|
92
|
-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
93
|
-
|
|
94
68
|
build-linux-node:
|
|
95
69
|
name: Node.js ${{matrix.node-version}} on CentOS 7
|
|
96
70
|
needs: create-release
|
|
97
71
|
runs-on: ubuntu-latest
|
|
72
|
+
continue-on-error: true
|
|
98
73
|
|
|
99
74
|
strategy:
|
|
100
75
|
matrix:
|
|
101
|
-
node-version: [12, 14,
|
|
76
|
+
node-version: [12, 14, 16, 17]
|
|
102
77
|
|
|
103
78
|
steps:
|
|
104
79
|
- uses: actions/checkout@v2
|
|
@@ -123,10 +98,11 @@ jobs:
|
|
|
123
98
|
with:
|
|
124
99
|
node-version: ${{matrix.node-version}}
|
|
125
100
|
|
|
126
|
-
build-linux-alpine-node-
|
|
127
|
-
name: Node.js
|
|
101
|
+
build-linux-alpine-node-12:
|
|
102
|
+
name: Node.js 12 on Alpine Linux
|
|
128
103
|
needs: create-release
|
|
129
104
|
runs-on: ubuntu-latest
|
|
105
|
+
continue-on-error: true
|
|
130
106
|
|
|
131
107
|
steps:
|
|
132
108
|
- uses: actions/checkout@v2
|
|
@@ -145,14 +121,15 @@ jobs:
|
|
|
145
121
|
Linux-Alpine-node-
|
|
146
122
|
Linux-Alpine-
|
|
147
123
|
- name: Install, test, and create artifact
|
|
148
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
124
|
+
uses: ./.github/actions/linux-alpine-node-12/
|
|
149
125
|
env:
|
|
150
126
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
151
127
|
|
|
152
|
-
build-linux-alpine-node-
|
|
153
|
-
name: Node.js
|
|
128
|
+
build-linux-alpine-node-14:
|
|
129
|
+
name: Node.js 14 on Alpine Linux
|
|
154
130
|
needs: create-release
|
|
155
131
|
runs-on: ubuntu-latest
|
|
132
|
+
continue-on-error: true
|
|
156
133
|
|
|
157
134
|
steps:
|
|
158
135
|
- uses: actions/checkout@v2
|
|
@@ -171,14 +148,15 @@ jobs:
|
|
|
171
148
|
Linux-Alpine-node-
|
|
172
149
|
Linux-Alpine-
|
|
173
150
|
- name: Install, test, and create artifact
|
|
174
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
151
|
+
uses: ./.github/actions/linux-alpine-node-14/
|
|
175
152
|
env:
|
|
176
153
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
177
154
|
|
|
178
|
-
build-linux-alpine-node-
|
|
179
|
-
name: Node.js
|
|
155
|
+
build-linux-alpine-node-16:
|
|
156
|
+
name: Node.js 16 on Alpine Linux
|
|
180
157
|
needs: create-release
|
|
181
158
|
runs-on: ubuntu-latest
|
|
159
|
+
continue-on-error: true
|
|
182
160
|
|
|
183
161
|
steps:
|
|
184
162
|
- uses: actions/checkout@v2
|
|
@@ -197,14 +175,15 @@ jobs:
|
|
|
197
175
|
Linux-Alpine-node-
|
|
198
176
|
Linux-Alpine-
|
|
199
177
|
- name: Install, test, and create artifact
|
|
200
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
178
|
+
uses: ./.github/actions/linux-alpine-node-16/
|
|
201
179
|
env:
|
|
202
180
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
203
181
|
|
|
204
|
-
build-linux-alpine-node-
|
|
205
|
-
name: Node.js
|
|
182
|
+
build-linux-alpine-node-17:
|
|
183
|
+
name: Node.js 17 on Alpine Linux
|
|
206
184
|
needs: create-release
|
|
207
185
|
runs-on: ubuntu-latest
|
|
186
|
+
continue-on-error: true
|
|
208
187
|
|
|
209
188
|
steps:
|
|
210
189
|
- uses: actions/checkout@v2
|
|
@@ -223,6 +202,6 @@ jobs:
|
|
|
223
202
|
Linux-Alpine-node-
|
|
224
203
|
Linux-Alpine-
|
|
225
204
|
- name: Install, test, and create artifact
|
|
226
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
205
|
+
uses: ./.github/actions/linux-alpine-node-17/
|
|
227
206
|
env:
|
|
228
207
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
package/README.md
CHANGED
|
@@ -13,6 +13,10 @@ at his [Implementing Regular Expressions](http://swtch.com/~rsc/regexp/) page.
|
|
|
13
13
|
(see [Syntax](https://github.com/google/re2/wiki/Syntax)),
|
|
14
14
|
but it lacks two features: backreferences and lookahead assertions. See below for more details.
|
|
15
15
|
|
|
16
|
+
`RE2` always works in the [Unicode mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode), which means that all matches that use character codes are interpret as Unicode code points, not as binary values of UTF-16.
|
|
17
|
+
See `RE2.unicodeWarningLevel` below for more details.
|
|
18
|
+
|
|
19
|
+
|
|
16
20
|
`RE2` object emulates standard `RegExp` making it a practical drop-in replacement in most cases.
|
|
17
21
|
`RE2` is extended to provide `String`-based regular expression methods as well. To help to convert
|
|
18
22
|
`RegExp` objects to `RE2` its constructor can take `RegExp` directly honoring all properties.
|
|
@@ -211,7 +215,7 @@ For example, [yarn](https://yarnpkg.com/) is known to fail in some scenarios
|
|
|
211
215
|
|
|
212
216
|
### Precompiled artifacts
|
|
213
217
|
|
|
214
|
-
When installing re2 the [install script](
|
|
218
|
+
When installing re2 the [install script](https://github.com/uhop/install-artifact-from-github/blob/master/bin/install-from-cache.js) attempts to download a prebuilt artifact for your system from the Github releases. The download location can be overridden by setting the `RE2_DOWNLOAD_MIRROR` environment variable as seen in the install script.
|
|
215
219
|
|
|
216
220
|
If all attempts to download the prebuilt artifact for your system fails the script attempts to built re2 locally on your machine using [node-gyp](https://github.com/nodejs/node-gyp).
|
|
217
221
|
|
|
@@ -343,6 +347,10 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
343
347
|
|
|
344
348
|
## Release history
|
|
345
349
|
|
|
350
|
+
- 1.17.2 *Added support for the enhanced local mirroring by updating [install-artifact-from-github](https://github.com/uhop/install-artifact-from-github).*
|
|
351
|
+
- 1.17.1 *Fix for `lastIndex` for U+10000 - U+10FFFF UTF characters. Thx, [omg](https://github.com/omg).*
|
|
352
|
+
- 1.17.0 *Updated GYP, added support for Node 17, updated deps.*
|
|
353
|
+
- 1.16.0 *Updated the compiler (thx, [Sergei Dyshel](https://github.com/sergei-dyshel)), updated GYP, removed support for Node 10, added support for Node 16, updated TS bindings (thx, [BannerBomb](https://github.com/BannerBomb)).*
|
|
346
354
|
- 1.15.9 *Updated deps.*
|
|
347
355
|
- 1.15.8 *Updated deps.*
|
|
348
356
|
- 1.15.7 *Updated deps.*
|
|
@@ -353,40 +361,8 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
353
361
|
- 1.15.2 *Added `linux-musl` target for precompiled images (thx [Uzlopak](https://github.com/Uzlopak)).*
|
|
354
362
|
- 1.15.1 *Refreshed dependencies, updated the verification check on installation, general maintenance.*
|
|
355
363
|
- 1.15.0 *Fix for multiline expressions (thx [Frederic Rudman](https://github.com/frudman)), `toString()` uses `source` now, updated deps.*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
- 1.13.0 *Got rid of a single static variable to support multithreading.*
|
|
359
|
-
- 1.12.1 *Updated re2 to the latest version.*
|
|
360
|
-
- 1.12.0 *Updated the way `RE2` objects are constructed.*
|
|
361
|
-
- 1.11.0 *Updated the way to initialize the extension (thx [BannerBomb](https://github.com/BannerBomb)).*
|
|
362
|
-
- 1.10.5 *Bugfix for optional groups (thx [Josh Yudaken](https://github.com/qix)), the latest version of re2.*
|
|
363
|
-
- 1.10.4 *Technical release: even better TypeScript types (thx [Louis Brann](https://github.com/louis-brann)).*
|
|
364
|
-
- 1.10.3 *Technical release: missing reference to TS types (thx [Jamie Magee](https://github.com/JamieMagee)).*
|
|
365
|
-
- 1.10.2 *Technical release: added TypeScript types (thx [Jamie Magee](https://github.com/JamieMagee)).*
|
|
366
|
-
- 1.10.1 *Updated re2 to the latest version (thx [Jamie Magee](https://github.com/JamieMagee)), dropped Node 6.*
|
|
367
|
-
- 1.10.0 *Added back support for Node 6 and Node 8. Now Node 6-12 is supported.*
|
|
368
|
-
- 1.9.0 *Refreshed dependencies to support Node 12. Only versions 10-12 are supported now (`v8` restrictions). For older versions use `node-re2@1.8`.*
|
|
369
|
-
- 1.8.4 *Refreshed dependencies, removed `unistd.h` to compile on Windows.*
|
|
370
|
-
- 1.8.3 *Refreshed dependencies, removed suppression of some warnings.*
|
|
371
|
-
- 1.8.2 *Bugfix to support the null prototype for groups. Thx [Exter-N](https://github.com/Exter-N).*
|
|
372
|
-
- 1.8.1 *Bugfix for better source escaping.*
|
|
373
|
-
- 1.8.0 *Clarified Unicode support, added `unicode` flag, added named groups — thx [Exter-N](https://github.com/Exter-N)! Bugfixes — thx [Barak Amar](https://github.com/nopcoder).*
|
|
374
|
-
- 1.7.0 *Implemented `sticky` and `flags` + bug fixes + more tests. Thx [Exter-N](https://github.com/Exter-N).*
|
|
375
|
-
- 1.6.2 *Bugfix for a prototype access. Thx [Exter-N](https://github.com/Exter-N).*
|
|
376
|
-
- 1.6.1 *Returned support for node 4 LTS. Thx [Kannan Goundan](https://github.com/cakoose).*
|
|
377
|
-
- 1.6.0 *Added well-known symbol-based methods of ES6. Refreshed NAN.*
|
|
378
|
-
- 1.5.0 *Bugfixes, error checks, better docs. Thx [Jamie Davis](https://github.com/davisjam), and [omg](https://github.com/omg).*
|
|
379
|
-
- 1.4.1 *Minor corrections in README.*
|
|
380
|
-
- 1.4.0 *Use re2 as a git submodule. Thx [Ben James](https://github.com/benhjames).*
|
|
381
|
-
- 1.3.3 *Refreshed dependencies.*
|
|
382
|
-
- 1.3.2 *Updated references in README (re2 was moved to github).*
|
|
383
|
-
- 1.3.1 *Refreshed dependencies, new Travis-CI config.*
|
|
384
|
-
- 1.3.0 *Upgraded NAN to 1.6.3, now we support node.js 0.10.36, 0.12.0, and io.js 1.3.0. Thx [Reid Burke](https://github.com/reid)!*
|
|
385
|
-
- 1.2.0 *Documented getUtfXLength() functions. Added support for `\c` and `\u` commands.*
|
|
386
|
-
- 1.1.1 *Minor corrections in README.*
|
|
387
|
-
- 1.1.0 *Buffer-based API is public. Unicode is fully supported.*
|
|
388
|
-
- 1.0.0 *Implemented all `RegExp` methods, and all relevant `String` methods.*
|
|
389
|
-
- 0.9.0 *The initial public release.*
|
|
364
|
+
|
|
365
|
+
The rest can be consulted in the project's wiki [Release history](https://github.com/uhop/node-re2/wiki/Release-history).
|
|
390
366
|
|
|
391
367
|
## License
|
|
392
368
|
|
package/binding.gyp
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vendor/util/strutil.cc"
|
|
40
40
|
],
|
|
41
41
|
"cflags": [
|
|
42
|
-
"-std=c++
|
|
42
|
+
"-std=c++14",
|
|
43
43
|
"-Wall",
|
|
44
44
|
"-Wextra",
|
|
45
45
|
"-Wno-sign-compare",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"CLANG_CXX_LANGUAGE_STANDARD": "c++11",
|
|
63
63
|
"CLANG_CXX_LIBRARY": "libc++",
|
|
64
64
|
"OTHER_CFLAGS": [
|
|
65
|
-
"-std=c++
|
|
65
|
+
"-std=c++14",
|
|
66
66
|
"-Wall",
|
|
67
67
|
"-Wextra",
|
|
68
68
|
"-Wno-sign-compare",
|
package/lib/exec.cc
CHANGED
|
@@ -50,7 +50,10 @@ NAN_METHOD(WrappedRE2::Exec)
|
|
|
50
50
|
}
|
|
51
51
|
for (size_t n = re2->lastIndex; n; --n)
|
|
52
52
|
{
|
|
53
|
-
|
|
53
|
+
size_t s = getUtf8CharSize(str.data[lastIndex]);
|
|
54
|
+
lastIndex += s;
|
|
55
|
+
if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters
|
|
56
|
+
// the decrement above is protected to avoid an overflow of an unsigned integer
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
package/lib/match.cc
CHANGED
|
@@ -59,7 +59,10 @@ NAN_METHOD(WrappedRE2::Match)
|
|
|
59
59
|
{
|
|
60
60
|
for (size_t n = re2->lastIndex; n; --n)
|
|
61
61
|
{
|
|
62
|
-
|
|
62
|
+
size_t s = getUtf8CharSize(a.data[lastIndex]);
|
|
63
|
+
lastIndex += s;
|
|
64
|
+
if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters
|
|
65
|
+
// the decrement above is protected to avoid an overflow of an unsigned integer
|
|
63
66
|
}
|
|
64
67
|
anchor = RE2::ANCHOR_START;
|
|
65
68
|
}
|
package/lib/replace.cc
CHANGED
|
@@ -226,7 +226,10 @@ static Nan::Maybe<std::string> replace(WrappedRE2 *re2, const StrVal &replacee,
|
|
|
226
226
|
{
|
|
227
227
|
for (size_t n = re2->lastIndex; n; --n)
|
|
228
228
|
{
|
|
229
|
-
|
|
229
|
+
size_t s = getUtf8CharSize(data[lastIndex]);
|
|
230
|
+
lastIndex += s;
|
|
231
|
+
if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters
|
|
232
|
+
// the decrement above is protected to avoid an overflow of an unsigned integer
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
}
|
|
@@ -372,7 +375,10 @@ static Nan::Maybe<std::string> replace(WrappedRE2 *re2, const StrVal &replacee,
|
|
|
372
375
|
{
|
|
373
376
|
for (size_t n = re2->lastIndex; n; --n)
|
|
374
377
|
{
|
|
375
|
-
|
|
378
|
+
size_t s = getUtf8CharSize(data[lastIndex]);
|
|
379
|
+
lastIndex += s;
|
|
380
|
+
if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters
|
|
381
|
+
// the decrement above is protected to avoid an overflow of an unsigned integer
|
|
376
382
|
}
|
|
377
383
|
}
|
|
378
384
|
}
|
package/lib/test.cc
CHANGED
|
@@ -50,7 +50,10 @@ NAN_METHOD(WrappedRE2::Test)
|
|
|
50
50
|
}
|
|
51
51
|
for (size_t n = re2->lastIndex; n; --n)
|
|
52
52
|
{
|
|
53
|
-
|
|
53
|
+
size_t s = getUtf8CharSize(str.data[lastIndex]);
|
|
54
|
+
lastIndex += s;
|
|
55
|
+
if (s == 4 && n >= 2) --n; // this utf8 character will take two utf16 characters
|
|
56
|
+
// the decrement above is protected to avoid an overflow of an unsigned integer
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "re2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.2",
|
|
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",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"test": "tests"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"install-artifact-from-github": "^1.
|
|
14
|
-
"nan": "^2.
|
|
15
|
-
"node-gyp": "^
|
|
13
|
+
"install-artifact-from-github": "^1.3.0",
|
|
14
|
+
"nan": "^2.15.0",
|
|
15
|
+
"node-gyp": "^8.4.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"heya-unit": "^0.3.0"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test": "node tests/tests.js",
|
|
22
22
|
"save-to-github": "save-to-github-cache --artifact build/Release/re2.node",
|
|
23
|
-
"install": "install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild",
|
|
23
|
+
"install": "install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || npm run rebuild",
|
|
24
24
|
"verify-build": "node scripts/verify-build.js",
|
|
25
25
|
"rebuild": "node-gyp rebuild"
|
|
26
26
|
},
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"text processing",
|
|
36
36
|
"PCRE alternative"
|
|
37
37
|
],
|
|
38
|
-
"author": "Eugene Lazutkin <eugene.lazutkin@gmail.com> (
|
|
38
|
+
"author": "Eugene Lazutkin <eugene.lazutkin@gmail.com> (https://lazutkin.com/)",
|
|
39
39
|
"license": "BSD-3-Clause"
|
|
40
40
|
}
|
package/re2.d.ts
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
declare module 're2' {
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
interface RE2MatchArray<K> extends Array<K> {
|
|
4
|
+
index?: number;
|
|
5
|
+
input?: K;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface RE2ExecArray<K> extends Array<K> {
|
|
9
|
+
index: number;
|
|
10
|
+
input: K;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface RE2 extends RegExp {
|
|
14
|
+
exec<K extends String | Buffer>(str: K): RE2ExecArray<K> | null;
|
|
15
|
+
|
|
16
|
+
test(str: string | Buffer): boolean;
|
|
17
|
+
|
|
18
|
+
match<K extends String | Buffer>(str: K): RE2MatchArray<K> | null;
|
|
19
|
+
|
|
20
|
+
replace<K extends String | Buffer>(str: K, replaceValue: string | Buffer): K;
|
|
21
|
+
replace<K extends String | Buffer>(str: K, replacer: (substring: string, ...args: any[]) => string | Buffer): K;
|
|
22
|
+
|
|
23
|
+
search(str: string | Buffer): number;
|
|
24
|
+
|
|
25
|
+
split<K extends String | Buffer>(str: K, limit?: number): K[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface RE2Constructor extends RegExpConstructor {
|
|
29
|
+
new(pattern: Buffer | RegExp | string): RE2;
|
|
30
|
+
new(pattern: Buffer | string, flags?: string): RE2;
|
|
31
|
+
(pattern: Buffer | RegExp | string): RE2;
|
|
32
|
+
(pattern: Buffer | string, flags?: string): RE2;
|
|
33
|
+
readonly prototype: RE2;
|
|
34
|
+
|
|
35
|
+
unicodeWarningLevel: 'nothing' | 'warnOnce' | 'warn' | 'throw';
|
|
36
|
+
getUtf8Length(value: string): number;
|
|
37
|
+
getUtf16Length(value: Buffer): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var RE2: RE2Constructor;
|
|
3
41
|
export = RE2;
|
|
4
42
|
}
|
|
5
|
-
|
package/tests/test_exec.js
CHANGED
|
@@ -284,6 +284,22 @@ unit.add(module, [
|
|
|
284
284
|
eval(t.TEST("re2.lastIndex === 6"));
|
|
285
285
|
},
|
|
286
286
|
|
|
287
|
+
function test_execSupplemental(t) {
|
|
288
|
+
"use strict";
|
|
289
|
+
|
|
290
|
+
var re = new RE2("\\w+", "g");
|
|
291
|
+
var testString = "🤡🤡🤡 Hello clown world!";
|
|
292
|
+
|
|
293
|
+
var result = re.exec(testString);
|
|
294
|
+
eval(t.TEST("t.unify(result, ['Hello'])"));
|
|
295
|
+
|
|
296
|
+
result = re.exec(testString);
|
|
297
|
+
eval(t.TEST("t.unify(result, ['clown'])"));
|
|
298
|
+
|
|
299
|
+
result = re.exec(testString);
|
|
300
|
+
eval(t.TEST("t.unify(result, ['world'])"));
|
|
301
|
+
},
|
|
302
|
+
|
|
287
303
|
// Multiline test
|
|
288
304
|
|
|
289
305
|
function test_execMultiline(t) {
|
package/tests/test_general.js
CHANGED
|
@@ -209,6 +209,12 @@ unit.add(module, [
|
|
|
209
209
|
eval(t.TEST("s3.length === 1"));
|
|
210
210
|
eval(t.TEST("RE2.getUtf8Length(s3) === 3"));
|
|
211
211
|
|
|
212
|
+
var s4 = "🤡";
|
|
213
|
+
|
|
214
|
+
eval(t.TEST("s4.length === 2"));
|
|
215
|
+
eval(t.TEST("RE2.getUtf8Length(s4) === 4"));
|
|
216
|
+
eval(t.TEST("RE2.getUtf16Length(Buffer.from(s4, 'utf8')) === s4.length"));
|
|
217
|
+
|
|
212
218
|
var b3 = new Buffer([0xF0]);
|
|
213
219
|
|
|
214
220
|
eval(t.TEST("b3.length === 1"));
|
package/vendor/README
CHANGED
|
@@ -31,10 +31,12 @@ The Python wrapper is at https://github.com/google/re2/tree/abseil/python
|
|
|
31
31
|
and on PyPI (https://pypi.org/project/google-re2/).
|
|
32
32
|
|
|
33
33
|
A C wrapper is at https://github.com/marcomaggi/cre2/.
|
|
34
|
+
A D wrapper is at https://github.com/ShigekiKarita/re2d/ and on DUB (code.dlang.org).
|
|
34
35
|
An Erlang wrapper is at https://github.com/dukesoferl/re2/ and on Hex (hex.pm).
|
|
35
36
|
An Inferno wrapper is at https://github.com/powerman/inferno-re2/.
|
|
36
37
|
A Node.js wrapper is at https://github.com/uhop/node-re2/ and on NPM (npmjs.com).
|
|
37
38
|
An OCaml wrapper is at https://github.com/janestreet/re2/ and on OPAM (opam.ocaml.org).
|
|
38
39
|
A Perl wrapper is at https://github.com/dgl/re-engine-RE2/ and on CPAN (cpan.org).
|
|
39
|
-
An R wrapper is at https://github.com/
|
|
40
|
+
An R wrapper is at https://github.com/girishji/re2/ and on CRAN (cran.r-project.org).
|
|
40
41
|
A Ruby wrapper is at https://github.com/mudge/re2/ and on RubyGems (rubygems.org).
|
|
42
|
+
A WebAssembly wrapper is at https://github.com/google/re2-wasm/ and on NPM (npmjs.com).
|
package/vendor/re2/bitstate.cc
CHANGED
|
@@ -293,9 +293,9 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context,
|
|
|
293
293
|
context_ = context;
|
|
294
294
|
if (context_.data() == NULL)
|
|
295
295
|
context_ = text;
|
|
296
|
-
if (prog_->anchor_start() && context_
|
|
296
|
+
if (prog_->anchor_start() && BeginPtr(context_) != BeginPtr(text))
|
|
297
297
|
return false;
|
|
298
|
-
if (prog_->anchor_end() && context_
|
|
298
|
+
if (prog_->anchor_end() && EndPtr(context_) != EndPtr(text))
|
|
299
299
|
return false;
|
|
300
300
|
anchored_ = anchored || prog_->anchor_start();
|
|
301
301
|
longest_ = longest || prog_->anchor_end();
|
|
@@ -377,7 +377,7 @@ bool Prog::SearchBitState(const StringPiece& text,
|
|
|
377
377
|
bool longest = kind != kFirstMatch;
|
|
378
378
|
if (!b.Search(text, context, anchored, longest, match, nmatch))
|
|
379
379
|
return false;
|
|
380
|
-
if (kind == kFullMatch && match[0]
|
|
380
|
+
if (kind == kFullMatch && EndPtr(match[0]) != EndPtr(text))
|
|
381
381
|
return false;
|
|
382
382
|
return true;
|
|
383
383
|
}
|