File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
tests/MongoDB.Bson.Tests/IO Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,7 @@ private static JsonToken GetRegularExpressionToken(JsonBuffer buffer)
369
369
{
370
370
case '/' : state = RegularExpressionState . InOptions ; break ;
371
371
case '\\ ' : state = RegularExpressionState . InEscapeSequence ; break ;
372
+ case - 1 : state = RegularExpressionState . Invalid ; break ;
372
373
default : state = RegularExpressionState . InPattern ; break ;
373
374
}
374
375
break ;
Original file line number Diff line number Diff line change 13
13
* limitations under the License.
14
14
*/
15
15
16
+ using System ;
16
17
using MongoDB . Bson . IO ;
17
18
using Xunit ;
18
19
@@ -405,6 +406,20 @@ public void TestMinusZeroExponentMinusTwelve()
405
406
Assert . Equal ( ',' , buffer . Read ( ) ) ;
406
407
}
407
408
409
+ [ Theory ]
410
+ [ InlineData ( "/" ) ]
411
+ [ InlineData ( "/pattern" ) ]
412
+ [ InlineData ( "/pattern\\ /" ) ]
413
+ public void TestMissingClosingSlash ( string jsonRegex )
414
+ {
415
+ var buffer = new JsonBuffer ( jsonRegex ) ;
416
+
417
+ var exception = Record . Exception ( ( ) => JsonScanner . GetNextToken ( buffer ) ) ;
418
+
419
+ Assert . IsType < FormatException > ( exception ) ;
420
+ Assert . StartsWith ( "Invalid JSON regular expression" , exception . Message ) ;
421
+ }
422
+
408
423
[ Fact ]
409
424
public void TestRegularExpressionEmpty ( )
410
425
{
You can’t perform that action at this time.
0 commit comments