Skip to content

Commit 27f1d6e

Browse files
authored
CDRIVER-3773 Remove support for canonical regular expressions with no options (#754)
1 parent 2e685d1 commit 27f1d6e

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/libbson/src/bson/bson-json.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,10 @@ _bson_json_read_append_regex (bson_json_reader_t *reader, /* IN */
13931393
_bson_json_read_set_error (
13941394
reader, "Missing \"pattern\" after \"options\" in regular expression");
13951395
return;
1396+
} else if (!data->regex.has_options) {
1397+
_bson_json_read_set_error (
1398+
reader, "Missing \"options\" after \"pattern\" in regular expression");
1399+
return;
13961400
}
13971401

13981402
if (!bson_append_regex (STACK_BSON_CHILD,

src/libbson/tests/test-json.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,24 +1090,6 @@ test_bson_json_read_legacy_regex (void)
10901090
"Missing \"$regex\" after \"$options\"");
10911091
}
10921092

1093-
static void
1094-
test_bson_json_read_regex_no_options (void)
1095-
{
1096-
bson_t b;
1097-
bson_error_t error;
1098-
bool r;
1099-
const char *pattern;
1100-
const char *flags;
1101-
1102-
r = bson_init_from_json (
1103-
&b, "{\"a\": {\"$regularExpression\": { \"pattern\": \"abc\"}}}", -1, &error);
1104-
ASSERT_OR_PRINT (r, error);
1105-
BCON_EXTRACT (&b, "a", BCONE_REGEX (pattern, flags));
1106-
ASSERT_CMPSTR (pattern, "abc");
1107-
ASSERT_CMPSTR (flags, "");
1108-
1109-
bson_destroy (&b);
1110-
}
11111093

11121094
static void
11131095
test_bson_json_read_regex_options_order (void)
@@ -3468,8 +3450,6 @@ test_json_install (TestSuite *suite)
34683450
suite, "/bson/json/read/dbpointer", test_bson_json_read_dbpointer);
34693451
TestSuite_Add (
34703452
suite, "/bson/json/read/legacy_regex", test_bson_json_read_legacy_regex);
3471-
TestSuite_Add (
3472-
suite, "/bson/json/read/regex_no_options", test_bson_json_read_regex_no_options);
34733453
TestSuite_Add (suite,
34743454
"/bson/json/read/regex_options_order",
34753455
test_bson_json_read_regex_options_order);

0 commit comments

Comments
 (0)