@@ -145,6 +145,7 @@ namespace UnifiedRegex
145145 , tempLocationOfRange(nullptr )
146146 , codePointAtTempLocation(0 )
147147 , unicodeFlagPresent(false )
148+ , dotAllFlagPresent(false )
148149 , caseInsensitiveFlagPresent(false )
149150 , positionAfterLastSurrogate(nullptr )
150151 , valueOfLastSurrogate(INVALID_CODEPOINT)
@@ -2758,6 +2759,16 @@ namespace UnifiedRegex
27582759 }
27592760 flags = (RegexFlags)(flags | MultilineRegexFlag);
27602761 break ;
2762+ case ' s' :
2763+ if (scriptContext->GetConfig ()->IsES2018RegExDotAllEnabled ())
2764+ {
2765+ if ((flags & DotAllRegexFlag) != 0 )
2766+ {
2767+ Fail (JSERR_RegExpSyntax);
2768+ }
2769+ flags = (RegexFlags)(flags | DotAllRegexFlag);
2770+ break ;
2771+ }
27612772 case ' u' :
27622773 // If we don't have unicode enabled, fall through to default
27632774 if (scriptContext->GetConfig ()->IsES6UnicodeExtensionsEnabled ())
@@ -2832,12 +2843,15 @@ namespace UnifiedRegex
28322843 Fail (JSERR_RegExpSyntax);
28332844 this ->unicodeFlagPresent = (flags & UnifiedRegex::UnicodeRegexFlag) == UnifiedRegex::UnicodeRegexFlag;
28342845 this ->caseInsensitiveFlagPresent = (flags & UnifiedRegex::IgnoreCaseRegexFlag) == UnifiedRegex::IgnoreCaseRegexFlag;
2846+ this ->dotAllFlagPresent = (flags & UnifiedRegex::DotAllRegexFlag) == UnifiedRegex::DotAllRegexFlag;
28352847 Assert (!this ->unicodeFlagPresent || scriptContext->GetConfig ()->IsES6UnicodeExtensionsEnabled ());
2848+ Assert (!this ->dotAllFlagPresent || scriptContext->GetConfig ()->IsES2018RegExDotAllEnabled ());
28362849 }
28372850 else
28382851 {
28392852 this ->unicodeFlagPresent = false ;
28402853 this ->caseInsensitiveFlagPresent = false ;
2854+ this ->dotAllFlagPresent = false ;
28412855 }
28422856
28432857 // If this HR has been set, that means we have an earlier failure than the one caught above.
@@ -2891,6 +2905,7 @@ namespace UnifiedRegex
28912905 Options (flags);
28922906 this ->unicodeFlagPresent = (flags & UnifiedRegex::UnicodeRegexFlag) == UnifiedRegex::UnicodeRegexFlag;
28932907 this ->caseInsensitiveFlagPresent = (flags & UnifiedRegex::IgnoreCaseRegexFlag) == UnifiedRegex::IgnoreCaseRegexFlag;
2908+ this ->dotAllFlagPresent = (flags & UnifiedRegex::DotAllRegexFlag) == UnifiedRegex::DotAllRegexFlag;
28942909 Assert (!this ->unicodeFlagPresent || scriptContext->GetConfig ()->IsES6UnicodeExtensionsEnabled ());
28952910
28962911 // If this HR has been set, that means we have an earlier failure than the one caught above.
@@ -2946,6 +2961,7 @@ namespace UnifiedRegex
29462961 Options (dummyFlags);
29472962 this ->unicodeFlagPresent = (dummyFlags & UnifiedRegex::UnicodeRegexFlag) == UnifiedRegex::UnicodeRegexFlag;
29482963 this ->caseInsensitiveFlagPresent = (dummyFlags & UnifiedRegex::IgnoreCaseRegexFlag) == UnifiedRegex::IgnoreCaseRegexFlag;
2964+ this ->dotAllFlagPresent = (dummyFlags & UnifiedRegex::DotAllRegexFlag) == UnifiedRegex::DotAllRegexFlag;
29492965 outTotalEncodedChars = Chars<EncodedChar>::OSB (next, input);
29502966 outTotalChars = Pos ();
29512967
@@ -3101,7 +3117,14 @@ namespace UnifiedRegex
31013117 switch (cc)
31023118 {
31033119 case ' .' :
3104- standardChars->SetNonNewline (ctAllocator, partialPrefixSetNode->set );
3120+ if (this ->dotAllFlagPresent )
3121+ {
3122+ standardChars->SetFullSet (ctAllocator, partialPrefixSetNode->set );
3123+ }
3124+ else
3125+ {
3126+ standardChars->SetNonNewline (ctAllocator, partialPrefixSetNode->set );
3127+ }
31053128 break ;
31063129 case ' S' :
31073130 standardChars->SetNonWhitespace (ctAllocator, partialPrefixSetNode->set );
@@ -3137,7 +3160,14 @@ namespace UnifiedRegex
31373160 switch (cc)
31383161 {
31393162 case ' .' :
3140- standardChars->SetNonNewline (ctAllocator, setNode->set );
3163+ if (this ->dotAllFlagPresent )
3164+ {
3165+ standardChars->SetFullSet (ctAllocator, setNode->set );
3166+ }
3167+ else
3168+ {
3169+ standardChars->SetNonNewline (ctAllocator, setNode->set );
3170+ }
31413171 break ;
31423172 case ' S' :
31433173 standardChars->SetNonWhitespace (ctAllocator, setNode->set );
0 commit comments