Skip to content

PYTHON-2820 Test serialization of BSON with embedded null bytes in strings #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2021

Conversation

ShaneHarvey
Copy link
Member

No description provided.

@@ -51,6 +51,8 @@
# This variant of $numberLong may have been generated by an old version
# of mongoexport.
'Bad $numberLong (number, not string)',
# We parse Regex flags with extra characters, including nulls.
'Null byte in $regularExpression options',
Copy link
Member Author

@ShaneHarvey ShaneHarvey Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our Regex type ignores extra characters in "flags":

>>> Regex('', '1234567qwertyasdfvbn\x00')
Regex('', re.DOTALL)

Another example:

>>> json_util.loads('{"a" : {"$regularExpression" : { "pattern": "b", "options" : "ijkhasgdhb\\u0000"}}}')
{'a': Regex('b', re.IGNORECASE|re.DOTALL)}
>>> json_util.dumps(_)
'{"a": {"$regularExpression": {"pattern": "b", "options": "is"}}}'

@ShaneHarvey ShaneHarvey merged commit 90d4c6f into mongodb:master Sep 10, 2021
juliusgeo pushed a commit to juliusgeo/mongo-python-driver that referenced this pull request Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants