diff options
author | Jacob Evans <jacob.evans@10gen.com> | 2020-10-15 12:05:00 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-15 17:08:57 +0000 |
commit | 51caad0e005e1a6dc1bd529cb809ba0d7d5eef0d (patch) | |
tree | 47b43947fa576b8ed93634464a23f5f8f66f2a8c /src/mongo | |
parent | d30e67386b75d724f324246a8dae34065ee8250f (diff) | |
download | mongo-51caad0e005e1a6dc1bd529cb809ba0d7d5eef0d.tar.gz |
SERVER-51083 Fix cherry-pick for num arguments to RegexMatchExpression
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/matcher/expression_leaf.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_leaf_test.cpp | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp index b1ca9d30342..fd9d082c518 100644 --- a/src/mongo/db/matcher/expression_leaf.cpp +++ b/src/mongo/db/matcher/expression_leaf.cpp @@ -231,8 +231,8 @@ Status RegexMatchExpression::init(StringData path, StringData regex, StringData // isValidUTF8() checks for UTF-8 which does not map to a series of codepoints but does not // check the validity of the code points themselves. These situations do not cause problems // downstream so we do not do additional work to enforce that the code points are valid. - uassert( - 5108300, "Regular expression is invalid UTF-8", isValidUTF8(_regex) && isValidUTF8(_flags)); + if (!isValidUTF8(_regex) || !isValidUTF8(_flags)) + return Status{ErrorCodes::BadValue, "Regular expression is invalid UTF-8"}; _re.reset(new pcrecpp::RE(_regex.c_str(), flags2options(_flags.c_str()))); diff --git a/src/mongo/db/matcher/expression_leaf_test.cpp b/src/mongo/db/matcher/expression_leaf_test.cpp index af60b5f05d4..253d0795b77 100644 --- a/src/mongo/db/matcher/expression_leaf_test.cpp +++ b/src/mongo/db/matcher/expression_leaf_test.cpp @@ -918,9 +918,8 @@ TEST(RegexMatchExpression, TooLargePattern) { } TEST(RegexMatchExpression, RegexCannotBeInvalidUTF8) { - ASSERT_THROWS_CODE(RegexMatchExpression("path", "^\xff\xff", ""), AssertionException, 5108300); - ASSERT_THROWS_CODE( - RegexMatchExpression("path", "^42", "\xff\xff"), AssertionException, 5108300); + ASSERT_NOT_OK(RegexMatchExpression().init("path", "^\xff\xff", "")); + ASSERT_NOT_OK(RegexMatchExpression().init("path", "^42", "\xff\xff")); } TEST(RegexMatchExpression, MatchesElementSimplePrefix) { |