[CDRIVER-3773] libbson rejects regular expressions with no options field Created: 10/Aug/20 Updated: 02/Jun/21 Resolved: 10/Mar/21 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | 1.17.0 |
| Fix Version/s: | 1.18.0, 1.18.0-alpha |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Julius Park (Inactive) | Assignee: | Benji Rewis (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
This originally appeared in a test failure in python-bsonjs. This is the failing test: https://github.com/mongodb-labs/python-bsonjs/blob/2947fc596c76fa82e47b903785bf1411f1c9be05/test/test_bsonjs.py#L146-L149. It fails with these logs:
This specific test is loading legacy regex syntax without the $options field:
Though based on _bson_json_read_append_regex also rejects the canonical representation of a regex if the options field was missing, like:
If libbson is passing the BSON corpus tests, I imagine it is not required by the spec that we permit regular expressions without options field. But if other tools may produce this (as the comment in test_bsonjs.py says), it seems worthwhile to not reject. For more info about regex representation in JSON, see the extended JSON spec: https://github.com/mongodb/specifications/blob/master/source/extended-json.rst |
| Comments |
| Comment by Benji Rewis (Inactive) [ 11/Mar/21 ] |
|
As of the commit above, we now support legacy regexes with no options, but not canonical regexes with no options. |
| Comment by Githook User [ 11/Mar/21 ] |
|
Author: {'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}Message: |
| Comment by Shane Harvey [ 11/Mar/21 ] |
|
Benji and I spoke about this ticket and came to the realization that we're only asking for the legacy $regex behavior to be changed here, not the canonical $regularExpression format. So can we un-revert this change for $regex? |
| Comment by Benji Rewis (Inactive) [ 11/Mar/21 ] |
|
We cannot support regular expressions with no options without a spec change because of an existing spec test that checks for a parse error on a regex with no options. This ticket would require a larger spec change, which I will look into. For now, I'm reverting the change through this PR. |
| Comment by Githook User [ 11/Mar/21 ] |
|
Author: {'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}Message: Revert " This reverts commit 2e685d183a8d5670d439e40059a34327daed84c7. |
| Comment by Benji Rewis (Inactive) [ 10/Mar/21 ] |
|
_bson_json_read_append_regex now supports regular expressions without options in both the legacy and canonical formats. |
| Comment by Githook User [ 10/Mar/21 ] |
|
Author: {'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}Message: |
| Comment by Benji Rewis (Inactive) [ 09/Mar/21 ] |