[SERVER-8544] Regex option "ii" is accepted by JSON to BSON parser Created: 13/Feb/13  Updated: 04/Jun/19  Resolved: 04/Jun/19

Status: Closed
Project: Core Server
Component/s: Internal Code, Shell
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Bug Priority: Minor - P4
Reporter: Andrew Emil (Inactive) Assignee: Nathan Brown (Inactive)
Resolution: Done Votes: 0
Labels: neweng, platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

add the following test to jsontests.cpp

class RegexInvalidOption7 : public Bad {
virtual string json() const {
return "{ \"a\" :

{ \"$regex\" : \"test\", \"$options\" : \"ii\" }

}";
}
};

and the output is

JsonTests::FromJsonTests::RegexInvalidOption7 Expected expression fromjson( json() ) to throw MsgAssertionException but it threw nothing. @src/mongo/dbtests/jsontests.cpp:447

Sprint: Dev Tools 2019-06-03, Dev Tools 2019-06-17
Participants:

 Comments   
Comment by Githook User [ 04/Jun/19 ]

Author:

{'name': 'Nathan Brown', 'email': 'nathan.brown@10gen.com'}

Message: SERVER-8544 Disable having duplicate regex options in JSON parsing
Branch: master
https://github.com/mongodb/mongo/commit/34ff5d6e6ddb302634185549a2a5ee558d629ba2

Comment by Shaun Verch [ 23/Jun/14 ]

The following function is the only thing that needs to be modified to fix this: https://github.com/mongodb/mongo/blob/r2.7.2/src/mongo/db/json.cpp#L907

The existing unit tests for regular expressions in the JSON parser are here: https://github.com/mongodb/mongo/blob/r2.7.2/src/mongo/dbtests/jsontests.cpp#L1875 This is where the test for this fix should be added.

Generated at Thu Feb 08 03:17:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.