@@ -145,6 +145,7 @@ namespace UnifiedRegex
145
145
, tempLocationOfRange(nullptr )
146
146
, codePointAtTempLocation(0 )
147
147
, unicodeFlagPresent(false )
148
+ , dotAllFlagPresent(false )
148
149
, caseInsensitiveFlagPresent(false )
149
150
, positionAfterLastSurrogate(nullptr )
150
151
, valueOfLastSurrogate(INVALID_CODEPOINT)
@@ -2758,6 +2759,16 @@ namespace UnifiedRegex
2758
2759
}
2759
2760
flags = (RegexFlags)(flags | MultilineRegexFlag);
2760
2761
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
+ }
2761
2772
case ' u' :
2762
2773
// If we don't have unicode enabled, fall through to default
2763
2774
if (scriptContext->GetConfig ()->IsES6UnicodeExtensionsEnabled ())
@@ -2832,12 +2843,15 @@ namespace UnifiedRegex
2832
2843
Fail (JSERR_RegExpSyntax);
2833
2844
this ->unicodeFlagPresent = (flags & UnifiedRegex::UnicodeRegexFlag) == UnifiedRegex::UnicodeRegexFlag;
2834
2845
this ->caseInsensitiveFlagPresent = (flags & UnifiedRegex::IgnoreCaseRegexFlag) == UnifiedRegex::IgnoreCaseRegexFlag;
2846
+ this ->dotAllFlagPresent = (flags & UnifiedRegex::DotAllRegexFlag) == UnifiedRegex::DotAllRegexFlag;
2835
2847
Assert (!this ->unicodeFlagPresent || scriptContext->GetConfig ()->IsES6UnicodeExtensionsEnabled ());
2848
+ Assert (!this ->dotAllFlagPresent || scriptContext->GetConfig ()->IsES2018RegExDotAllEnabled ());
2836
2849
}
2837
2850
else
2838
2851
{
2839
2852
this ->unicodeFlagPresent = false ;
2840
2853
this ->caseInsensitiveFlagPresent = false ;
2854
+ this ->dotAllFlagPresent = false ;
2841
2855
}
2842
2856
2843
2857
// If this HR has been set, that means we have an earlier failure than the one caught above.
@@ -2891,6 +2905,7 @@ namespace UnifiedRegex
2891
2905
Options (flags);
2892
2906
this ->unicodeFlagPresent = (flags & UnifiedRegex::UnicodeRegexFlag) == UnifiedRegex::UnicodeRegexFlag;
2893
2907
this ->caseInsensitiveFlagPresent = (flags & UnifiedRegex::IgnoreCaseRegexFlag) == UnifiedRegex::IgnoreCaseRegexFlag;
2908
+ this ->dotAllFlagPresent = (flags & UnifiedRegex::DotAllRegexFlag) == UnifiedRegex::DotAllRegexFlag;
2894
2909
Assert (!this ->unicodeFlagPresent || scriptContext->GetConfig ()->IsES6UnicodeExtensionsEnabled ());
2895
2910
2896
2911
// If this HR has been set, that means we have an earlier failure than the one caught above.
@@ -2946,6 +2961,7 @@ namespace UnifiedRegex
2946
2961
Options (dummyFlags);
2947
2962
this ->unicodeFlagPresent = (dummyFlags & UnifiedRegex::UnicodeRegexFlag) == UnifiedRegex::UnicodeRegexFlag;
2948
2963
this ->caseInsensitiveFlagPresent = (dummyFlags & UnifiedRegex::IgnoreCaseRegexFlag) == UnifiedRegex::IgnoreCaseRegexFlag;
2964
+ this ->dotAllFlagPresent = (dummyFlags & UnifiedRegex::DotAllRegexFlag) == UnifiedRegex::DotAllRegexFlag;
2949
2965
outTotalEncodedChars = Chars<EncodedChar>::OSB (next, input);
2950
2966
outTotalChars = Pos ();
2951
2967
@@ -3101,7 +3117,14 @@ namespace UnifiedRegex
3101
3117
switch (cc)
3102
3118
{
3103
3119
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
+ }
3105
3128
break ;
3106
3129
case ' S' :
3107
3130
standardChars->SetNonWhitespace (ctAllocator, partialPrefixSetNode->set );
@@ -3137,7 +3160,14 @@ namespace UnifiedRegex
3137
3160
switch (cc)
3138
3161
{
3139
3162
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
+ }
3141
3171
break ;
3142
3172
case ' S' :
3143
3173
standardChars->SetNonWhitespace (ctAllocator, setNode->set );
0 commit comments