Skip to content

Wrap string in literal if it contains $ #1144

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
Jun 20, 2023

Conversation

katcharov
Copy link
Collaborator

@katcharov katcharov requested a review from vbabanin June 20, 2023 15:47
Comment on lines +257 to +264
private static BsonValue wrapString(final String s) {
BsonString bson = new BsonString(s);
if (s.contains("$")) {
return new BsonDocument("$literal", bson);
} else {
return bson;
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe "$" is the only character that would cause a string to need to be wrapped.

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

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

LGTM!

@katcharov katcharov merged commit 86b43d6 into mongodb:master Jun 20, 2023
@katcharov katcharov deleted the JAVA-4884 branch July 14, 2023 15:27
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