re2 1.15.8 → 1.17.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/.github/actions/linux-alpine-node-12/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-12/entrypoint.sh +1 -1
- package/.github/actions/linux-alpine-node-14/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-14/entrypoint.sh +1 -1
- package/.github/actions/{linux-alpine-node-10 → linux-alpine-node-16}/Dockerfile +2 -2
- package/.github/actions/linux-alpine-node-16/action.yml +7 -0
- package/.github/actions/{linux-alpine-node-10 → linux-alpine-node-16}/entrypoint.sh +2 -1
- package/.github/actions/linux-alpine-node-17/Dockerfile +6 -0
- package/.github/actions/linux-alpine-node-17/action.yml +7 -0
- package/.github/actions/linux-alpine-node-17/entrypoint.sh +9 -0
- package/.github/actions/linux-node-12/Dockerfile +5 -4
- package/.github/actions/linux-node-12/entrypoint.sh +1 -1
- package/.github/dependabot.yml +1 -1
- package/.github/workflows/build.yml +31 -26
- package/.github/workflows/tests.yml +2 -2
- package/README.md +7 -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 +4 -4
- 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 +91 -129
- package/vendor/re2/re2.h +119 -135
- 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/charclass_test.cc +2 -2
- 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_arg_test.cc +25 -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/vendor/util/pcre.h +3 -3
- package/.github/actions/linux-alpine-node-10/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
|
|
@@ -57,7 +57,7 @@ jobs:
|
|
|
57
57
|
env:
|
|
58
58
|
DEVELOPMENT_SKIP_GETTING_ASSET: true
|
|
59
59
|
run: |
|
|
60
|
-
npm
|
|
60
|
+
npm i
|
|
61
61
|
npm run build --if-present
|
|
62
62
|
npm test
|
|
63
63
|
- name: Save to GitHub
|
|
@@ -65,10 +65,15 @@ jobs:
|
|
|
65
65
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
66
66
|
run: npm run save-to-github
|
|
67
67
|
|
|
68
|
-
build-linux-node
|
|
69
|
-
name: Node.js
|
|
68
|
+
build-linux-node:
|
|
69
|
+
name: Node.js ${{matrix.node-version}} on CentOS 7
|
|
70
70
|
needs: create-release
|
|
71
71
|
runs-on: ubuntu-latest
|
|
72
|
+
continue-on-error: true
|
|
73
|
+
|
|
74
|
+
strategy:
|
|
75
|
+
matrix:
|
|
76
|
+
node-version: [12, 14, 16, 17]
|
|
72
77
|
|
|
73
78
|
steps:
|
|
74
79
|
- uses: actions/checkout@v2
|
|
@@ -87,18 +92,17 @@ jobs:
|
|
|
87
92
|
Linux-node-
|
|
88
93
|
Linux-
|
|
89
94
|
- name: Install, test, and create artifact
|
|
90
|
-
uses: ./.github/actions/linux-node-
|
|
95
|
+
uses: ./.github/actions/linux-node-12/
|
|
91
96
|
env:
|
|
92
97
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
98
|
+
with:
|
|
99
|
+
node-version: ${{matrix.node-version}}
|
|
93
100
|
|
|
94
|
-
build-linux-node:
|
|
95
|
-
name: Node.js
|
|
101
|
+
build-linux-alpine-node-12:
|
|
102
|
+
name: Node.js 12 on Alpine Linux
|
|
96
103
|
needs: create-release
|
|
97
104
|
runs-on: ubuntu-latest
|
|
98
|
-
|
|
99
|
-
strategy:
|
|
100
|
-
matrix:
|
|
101
|
-
node-version: [12, 14]
|
|
105
|
+
continue-on-error: true
|
|
102
106
|
|
|
103
107
|
steps:
|
|
104
108
|
- uses: actions/checkout@v2
|
|
@@ -112,21 +116,20 @@ jobs:
|
|
|
112
116
|
uses: actions/cache@v2
|
|
113
117
|
with:
|
|
114
118
|
path: ${{steps.npm-cache.outputs.dir}}
|
|
115
|
-
key: Linux-node-${{hashFiles('**/package-lock.json')}}
|
|
119
|
+
key: Linux-Alpine-node-${{hashFiles('**/package-lock.json')}}
|
|
116
120
|
restore-keys: |
|
|
117
|
-
Linux-node-
|
|
118
|
-
Linux-
|
|
121
|
+
Linux-Alpine-node-
|
|
122
|
+
Linux-Alpine-
|
|
119
123
|
- name: Install, test, and create artifact
|
|
120
|
-
uses: ./.github/actions/linux-node-12/
|
|
124
|
+
uses: ./.github/actions/linux-alpine-node-12/
|
|
121
125
|
env:
|
|
122
126
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
123
|
-
with:
|
|
124
|
-
node-version: ${{matrix.node-version}}
|
|
125
127
|
|
|
126
|
-
build-linux-alpine-node-
|
|
127
|
-
name: Node.js
|
|
128
|
+
build-linux-alpine-node-14:
|
|
129
|
+
name: Node.js 14 on Alpine Linux
|
|
128
130
|
needs: create-release
|
|
129
131
|
runs-on: ubuntu-latest
|
|
132
|
+
continue-on-error: true
|
|
130
133
|
|
|
131
134
|
steps:
|
|
132
135
|
- uses: actions/checkout@v2
|
|
@@ -145,14 +148,15 @@ jobs:
|
|
|
145
148
|
Linux-Alpine-node-
|
|
146
149
|
Linux-Alpine-
|
|
147
150
|
- name: Install, test, and create artifact
|
|
148
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
151
|
+
uses: ./.github/actions/linux-alpine-node-14/
|
|
149
152
|
env:
|
|
150
153
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
151
154
|
|
|
152
|
-
build-linux-alpine-node-
|
|
153
|
-
name: Node.js
|
|
155
|
+
build-linux-alpine-node-16:
|
|
156
|
+
name: Node.js 16 on Alpine Linux
|
|
154
157
|
needs: create-release
|
|
155
158
|
runs-on: ubuntu-latest
|
|
159
|
+
continue-on-error: true
|
|
156
160
|
|
|
157
161
|
steps:
|
|
158
162
|
- uses: actions/checkout@v2
|
|
@@ -171,14 +175,15 @@ jobs:
|
|
|
171
175
|
Linux-Alpine-node-
|
|
172
176
|
Linux-Alpine-
|
|
173
177
|
- name: Install, test, and create artifact
|
|
174
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
178
|
+
uses: ./.github/actions/linux-alpine-node-16/
|
|
175
179
|
env:
|
|
176
180
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
177
181
|
|
|
178
|
-
build-linux-alpine-node-
|
|
179
|
-
name: Node.js
|
|
182
|
+
build-linux-alpine-node-17:
|
|
183
|
+
name: Node.js 17 on Alpine Linux
|
|
180
184
|
needs: create-release
|
|
181
185
|
runs-on: ubuntu-latest
|
|
186
|
+
continue-on-error: true
|
|
182
187
|
|
|
183
188
|
steps:
|
|
184
189
|
- uses: actions/checkout@v2
|
|
@@ -197,6 +202,6 @@ jobs:
|
|
|
197
202
|
Linux-Alpine-node-
|
|
198
203
|
Linux-Alpine-
|
|
199
204
|
- name: Install, test, and create artifact
|
|
200
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
205
|
+
uses: ./.github/actions/linux-alpine-node-17/
|
|
201
206
|
env:
|
|
202
207
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
16
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
|
17
|
-
node-version: [
|
|
17
|
+
node-version: [12, 14, 16, 17]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v2
|
|
@@ -39,6 +39,6 @@ jobs:
|
|
|
39
39
|
env:
|
|
40
40
|
DEVELOPMENT_SKIP_GETTING_ASSET: true
|
|
41
41
|
run: |
|
|
42
|
-
npm
|
|
42
|
+
npm i
|
|
43
43
|
npm run build --if-present
|
|
44
44
|
npm test
|
package/README.md
CHANGED
|
@@ -211,7 +211,7 @@ For example, [yarn](https://yarnpkg.com/) is known to fail in some scenarios
|
|
|
211
211
|
|
|
212
212
|
### Precompiled artifacts
|
|
213
213
|
|
|
214
|
-
When installing re2 the [install script](
|
|
214
|
+
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
215
|
|
|
216
216
|
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
217
|
|
|
@@ -343,6 +343,10 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
343
343
|
|
|
344
344
|
## Release history
|
|
345
345
|
|
|
346
|
+
- 1.17.1 *Fix for `lastIndex` for U+10000 - U+10FFFF UTF characters. Thx, [omg](https://github.com/omg).*
|
|
347
|
+
- 1.17.0 *Updated GYP, added support for Node 17, updated deps.*
|
|
348
|
+
- 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)).*
|
|
349
|
+
- 1.15.9 *Updated deps.*
|
|
346
350
|
- 1.15.8 *Updated deps.*
|
|
347
351
|
- 1.15.7 *Updated deps.*
|
|
348
352
|
- 1.15.6 *Technical release: less dependencies for the build.*
|
|
@@ -352,40 +356,8 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
352
356
|
- 1.15.2 *Added `linux-musl` target for precompiled images (thx [Uzlopak](https://github.com/Uzlopak)).*
|
|
353
357
|
- 1.15.1 *Refreshed dependencies, updated the verification check on installation, general maintenance.*
|
|
354
358
|
- 1.15.0 *Fix for multiline expressions (thx [Frederic Rudman](https://github.com/frudman)), `toString()` uses `source` now, updated deps.*
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
- 1.13.0 *Got rid of a single static variable to support multithreading.*
|
|
358
|
-
- 1.12.1 *Updated re2 to the latest version.*
|
|
359
|
-
- 1.12.0 *Updated the way `RE2` objects are constructed.*
|
|
360
|
-
- 1.11.0 *Updated the way to initialize the extension (thx [BannerBomb](https://github.com/BannerBomb)).*
|
|
361
|
-
- 1.10.5 *Bugfix for optional groups (thx [Josh Yudaken](https://github.com/qix)), the latest version of re2.*
|
|
362
|
-
- 1.10.4 *Technical release: even better TypeScript types (thx [Louis Brann](https://github.com/louis-brann)).*
|
|
363
|
-
- 1.10.3 *Technical release: missing reference to TS types (thx [Jamie Magee](https://github.com/JamieMagee)).*
|
|
364
|
-
- 1.10.2 *Technical release: added TypeScript types (thx [Jamie Magee](https://github.com/JamieMagee)).*
|
|
365
|
-
- 1.10.1 *Updated re2 to the latest version (thx [Jamie Magee](https://github.com/JamieMagee)), dropped Node 6.*
|
|
366
|
-
- 1.10.0 *Added back support for Node 6 and Node 8. Now Node 6-12 is supported.*
|
|
367
|
-
- 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`.*
|
|
368
|
-
- 1.8.4 *Refreshed dependencies, removed `unistd.h` to compile on Windows.*
|
|
369
|
-
- 1.8.3 *Refreshed dependencies, removed suppression of some warnings.*
|
|
370
|
-
- 1.8.2 *Bugfix to support the null prototype for groups. Thx [Exter-N](https://github.com/Exter-N).*
|
|
371
|
-
- 1.8.1 *Bugfix for better source escaping.*
|
|
372
|
-
- 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).*
|
|
373
|
-
- 1.7.0 *Implemented `sticky` and `flags` + bug fixes + more tests. Thx [Exter-N](https://github.com/Exter-N).*
|
|
374
|
-
- 1.6.2 *Bugfix for a prototype access. Thx [Exter-N](https://github.com/Exter-N).*
|
|
375
|
-
- 1.6.1 *Returned support for node 4 LTS. Thx [Kannan Goundan](https://github.com/cakoose).*
|
|
376
|
-
- 1.6.0 *Added well-known symbol-based methods of ES6. Refreshed NAN.*
|
|
377
|
-
- 1.5.0 *Bugfixes, error checks, better docs. Thx [Jamie Davis](https://github.com/davisjam), and [omg](https://github.com/omg).*
|
|
378
|
-
- 1.4.1 *Minor corrections in README.*
|
|
379
|
-
- 1.4.0 *Use re2 as a git submodule. Thx [Ben James](https://github.com/benhjames).*
|
|
380
|
-
- 1.3.3 *Refreshed dependencies.*
|
|
381
|
-
- 1.3.2 *Updated references in README (re2 was moved to github).*
|
|
382
|
-
- 1.3.1 *Refreshed dependencies, new Travis-CI config.*
|
|
383
|
-
- 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)!*
|
|
384
|
-
- 1.2.0 *Documented getUtfXLength() functions. Added support for `\c` and `\u` commands.*
|
|
385
|
-
- 1.1.1 *Minor corrections in README.*
|
|
386
|
-
- 1.1.0 *Buffer-based API is public. Unicode is fully supported.*
|
|
387
|
-
- 1.0.0 *Implemented all `RegExp` methods, and all relevant `String` methods.*
|
|
388
|
-
- 0.9.0 *The initial public release.*
|
|
359
|
+
|
|
360
|
+
The rest can be consulted in the project's wiki [Release history](https://github.com/uhop/node-re2/wiki/Release-history).
|
|
389
361
|
|
|
390
362
|
## License
|
|
391
363
|
|
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.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",
|
|
@@ -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.2.0",
|
|
14
|
+
"nan": "^2.15.0",
|
|
15
|
+
"node-gyp": "^8.4.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"heya-unit": "^0.3.0"
|
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
|
}
|