diff options
author | Nathan Brown <nathan.brown@10gen.com> | 2019-05-30 13:34:34 -0400 |
---|---|---|
committer | Nathan Brown <nathan.brown@10gen.com> | 2019-06-04 15:39:09 -0400 |
commit | 34ff5d6e6ddb302634185549a2a5ee558d629ba2 (patch) | |
tree | 0fadd0e71c9511ae9fcc96d460aebf6b132dc5b1 /src/mongo/bson | |
parent | 2d5d8aad8418d2b0bceb07871eef4591085ceac3 (diff) | |
download | mongo-34ff5d6e6ddb302634185549a2a5ee558d629ba2.tar.gz |
SERVER-8544 Disable having duplicate regex options in JSON parsing
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/bsonelement.cpp | 1 | ||||
-rw-r--r-- | src/mongo/bson/json.cpp | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp index 018b1f2e6e6..2ad980eb957 100644 --- a/src/mongo/bson/bsonelement.cpp +++ b/src/mongo/bson/bsonelement.cpp @@ -280,6 +280,7 @@ void BSONElement::jsonStringStream(JsonStringFormat format, case 'g': case 'i': case 'm': + case 's': s << *f; default: break; diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp index 8f6587a6eff..a2bc9872c79 100644 --- a/src/mongo/bson/json.cpp +++ b/src/mongo/bson/json.cpp @@ -993,10 +993,13 @@ Status JParse::regexOpt(std::string* result) { Status JParse::regexOptCheck(StringData opt) { MONGO_JSON_DEBUG("opt: " << opt); std::size_t i; + std::string availableOptions = JOPTIONS; for (i = 0; i < opt.size(); i++) { - if (!match(opt[i], JOPTIONS)) { + std::size_t availIndex = availableOptions.find(opt[i]); + if (availIndex == std::string::npos) { return parseError(string("Bad regex option: ") + opt[i]); } + availableOptions.erase(availIndex, 1); } return Status::OK(); } |