File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -666,7 +666,11 @@ def _parse_canonical_regex(doc):
666
666
if len (regex ) != 2 :
667
667
raise TypeError ('Bad $regularExpression must include only "pattern"'
668
668
'and "options" components: %s' % (doc ,))
669
- return Regex (regex ['pattern' ], regex ['options' ])
669
+ opts = regex ['options' ]
670
+ if not isinstance (opts , str ):
671
+ raise TypeError ('Bad $regularExpression options, options must be '
672
+ 'string, was type %s' % (type (opts )))
673
+ return Regex (regex ['pattern' ], opts )
670
674
671
675
672
676
def _parse_canonical_dbref (doc ):
Original file line number Diff line number Diff line change 92
92
},
93
93
{
94
94
"description" : " Bad $regularExpression (pattern is number, not string)" ,
95
- "string" : " {\" x\" : {\" $regularExpression\" : { \" pattern\" : 42, \" $ options\" : \"\" }}}"
95
+ "string" : " {\" x\" : {\" $regularExpression\" : { \" pattern\" : 42, \" options\" : \"\" }}}"
96
96
},
97
97
{
98
98
"description" : " Bad $regularExpression (options are number, not string)" ,
99
- "string" : " {\" x\" : {\" $regularExpression\" : { \" pattern\" : \" a\" , \" $ options\" : 0}}}"
99
+ "string" : " {\" x\" : {\" $regularExpression\" : { \" pattern\" : \" a\" , \" options\" : 0}}}"
100
100
},
101
101
{
102
102
"description" : " Bad $regularExpression (missing pattern field)" ,
You can’t perform that action at this time.
0 commit comments