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)
369369 {
370370 case '/' : state = RegularExpressionState . InOptions ; break ;
371371 case '\\ ' : state = RegularExpressionState . InEscapeSequence ; break ;
372+ case - 1 : state = RegularExpressionState . Invalid ; break ;
372373 default : state = RegularExpressionState . InPattern ; break ;
373374 }
374375 break ;
Original file line number Diff line number Diff line change 1313* limitations under the License.
1414*/
1515
16+ using System ;
1617using MongoDB . Bson . IO ;
1718using Xunit ;
1819
@@ -405,6 +406,20 @@ public void TestMinusZeroExponentMinusTwelve()
405406 Assert . Equal ( ',' , buffer . Read ( ) ) ;
406407 }
407408
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+
408423 [ Fact ]
409424 public void TestRegularExpressionEmpty ( )
410425 {
You can’t perform that action at this time.
0 commit comments