diff --git a/common.gypi b/common.gypi index 03233fedb64..214edd31cd8 100644 --- a/common.gypi +++ b/common.gypi @@ -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.46', + 'v8_embedder_string': '-node.47', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/regexp/regexp-compiler.cc b/deps/v8/src/regexp/regexp-compiler.cc index 23027f93012..397361031e5 100644 --- a/deps/v8/src/regexp/regexp-compiler.cc +++ b/deps/v8/src/regexp/regexp-compiler.cc @@ -2134,6 +2134,7 @@ EmitResult AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler, } bool at_boundary = (assertion_type_ == AssertionNode::AT_BOUNDARY); if (next_is_word_character == Trace::UNKNOWN) { + const RegExpFlags flags = compiler->flags(); Label before_non_word; Label before_word; if (trace->characters_preloaded() != 1) { @@ -2148,6 +2149,7 @@ EmitResult AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler, at_boundary ? kIsNonWord : kIsWord)); assembler->GoTo(&ok); + compiler->set_flags(flags); assembler->Bind(&before_word); RETURN_IF_ERROR(BacktrackIfPrevious(compiler, trace, at_boundary ? kIsWord : kIsNonWord)); diff --git a/deps/v8/test/mjsunit/regexp-modifiers.js b/deps/v8/test/mjsunit/regexp-modifiers.js index 72bf8840871..a57f266b606 100644 --- a/deps/v8/test/mjsunit/regexp-modifiers.js +++ b/deps/v8/test/mjsunit/regexp-modifiers.js @@ -89,3 +89,16 @@ test( /^(?-i:(?:a|b)(?:c|d)(?:e|f)(?:g|h)(?:i|j)(?:k|l)(?:m|n)x)/i, ['acegikmx', 'bdfhjlnx'], ['acegikmX', 'bdfhjlnX']); + +// Boundary assertions inside modifier groups with alternations must not leak +// flags between branches during code generation. +test(/(?i:\.|\bNULL)/, ['null', 'NULL', 'Null', '.foo'], ['xyz']); +test(/(?i:\bNULL|\.)/, ['null', 'NULL', '.foo'], ['xyz']); +test(/(?i:\.|\BNULL)/, ['xnull', 'xNULL'], ['null', 'xyz']); +test(/(?i:\W|\bNULL)/, ['null', 'NULL', '!'], ['x']); +test(/(?i:!|\?|\bNULL)/, ['null', 'NULL', '!', '?'], ['x']); +test(/(?i:\.|\bnUll)/, ['null', 'NULL']); +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']);