From 97b9a8f699bc16ec55747437564f2da9fb182e62 Mon Sep 17 00:00:00 2001 From: liwei Date: Thu, 19 Sep 2024 18:31:40 +0800 Subject: [PATCH] fix: DotAll flag with group --- parser/regexp.go | 4 ++++ regexp_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/parser/regexp.go b/parser/regexp.go index 0ea9b9d7..f455d0da 100644 --- a/parser/regexp.go +++ b/parser/regexp.go @@ -194,6 +194,10 @@ func (self *_RegExp_parser) scanGroup() { case '[': self.scanBracket() case '.': + if self.dotAll { + self.pass() + break + } self.writeString(Re2Dot) self.read() default: diff --git a/regexp_test.go b/regexp_test.go index 953db7f5..04498e51 100644 --- a/regexp_test.go +++ b/regexp_test.go @@ -718,7 +718,14 @@ func TestRegexpDotAll(t *testing.T) { re.test("\r") && re.test("\n") ` testScript(SCRIPT, valueTrue, t) +} +func TestRegexpDotAllInGroup(t *testing.T) { + const SCRIPT = ` + var re = /(.)/s; + re.test("\r") && re.test("\n") + ` + testScript(SCRIPT, valueTrue, t) } func TestRegexpNumSeparators(t *testing.T) {