mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
deps: V8: backport 1e7ee91de775
Original commit message:
[regexp] Reset flags between negative lookaround branches
e540e1161b0 (bug 510487690) reset the analysis-time flags between the
alternatives of a ChoiceNode, since an alternative's sub-graph may
contain a MODIFY_FLAGS node. NegativeLookaroundChoiceNode has its own
visitor and was left out, so a modifier group inside a negative
lookaround still leaks its flags into the continuation.
/(?!(?i:x|y))[K]/.exec('kz') // "k", should be null
The lookaround body is visited first and leaves the group's flags
behind; the continuation's class ranges are then made case independent
under those flags rather than the pattern's, so [K] picks up 'k'.
Only class ranges are affected: TextNode::MakeCaseIndependent
materializes the equivalents during analysis, while atoms get their case
closure at emission time from the restored flags. A single- alternative
body does not reproduce either, since its restore node is emitted last.
Change-Id: I4077076b9dbee6acf75918a2c4f7bf7d86cab059
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8175612
Auto-Submit: Jakob Linke <jgruber@chromium.org>
Reviewed-by: Patrick Thier <pthier@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#109043}
Refs: https://github.com/v8/v8/commit/1e7ee91de77500f9905ebbc5bed33c2186b1e871
Co-authored-by: Radu Samson <radu.samson@ext.ec.europa.eu>
Refs: https://github.com/nodejs/node/issues/66277
PR-URL: https://github.com/nodejs/node/pull/67207
Reviewed-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
e37da67f49
commit
748cfdc9f5
3 files changed
+11
-1
No files matched your search
+1
-1
@@ -44,7 +44,7 @@
|
||||
|
||||
# Reset this number to 0 on major V8 upgrades.
|
||||
# Increment by one for each non-official patch applied to deps/v8.
|
||||
'v8_embedder_string': '-node.47',
|
||||
'v8_embedder_string': '-node.48',
|
||||
|
||||
##### V8 defaults for Node.js #####
|
||||
|
||||
|
||||
+2
@@ -3889,11 +3889,13 @@ class Analysis : public NodeVisitor {
|
||||
NegativeLookaroundChoiceNode* that) override {
|
||||
DCHECK_EQ(that->alternatives()->length(), 2); // Lookaround and continue.
|
||||
|
||||
RegExpFlags header_flags = flags();
|
||||
EnsureAnalyzed(that->lookaround_node());
|
||||
if (has_failed()) return;
|
||||
STATIC_FOR_EACH(
|
||||
Propagators::VisitNegativeLookaroundChoiceLookaroundNode(that));
|
||||
|
||||
set_flags(header_flags);
|
||||
EnsureAnalyzed(that->continue_node());
|
||||
if (has_failed()) return;
|
||||
STATIC_FOR_EACH(
|
||||
|
||||
+8
@@ -102,3 +102,11 @@ test(/(?i:\.|\bnuLl)/, ['null', 'NULL']);
|
||||
test(/(?i:\.|\bnulL)/, ['null', 'NULL']);
|
||||
test(/(?-i:(?i:\.|\bNULL))/, ['null', 'NULL', '.foo'], ['xyz']);
|
||||
test(/(?i:(?-i:\.|\bNULL))/, ['NULL', '.foo'], ['null', 'xyz']);
|
||||
|
||||
// A modifier group inside a negative lookaround must not leak its flags into
|
||||
// the continuation. Analysis visits the two branches of the lookaround choice
|
||||
// in sequence, so without a reset the continuation's classes are made case
|
||||
// independent under the group's flags rather than the pattern's.
|
||||
test(/(?!(?i:x|y))[K]/, ['K'], ['k']);
|
||||
test(/(?<!(?i:x|y))[K]/, ['K'], ['k']);
|
||||
test(/(?!(?-i:x|y))[K]/i, ['K', 'k']);
|
||||
Reference in new issue
Block a user