Skip to content
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

fix: correctly escape field paths with multiple backslashes or backticks #2259

Merged

Conversation

albertnis
Copy link
Contributor

Previously, only the first backslash and backtick was being escaped. This broke update and set (merge) calls when a field path contained multiple backslashes.

replaceAll is an alternative here, but I think a global regex has better compatibility with older versions of Node.

Fixes #2019 🦕

@albertnis albertnis requested review from a team as code owners December 12, 2024 21:50
Copy link

google-cla bot commented Dec 12, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: firestore Issues related to the googleapis/nodejs-firestore API. labels Dec 12, 2024
Previously, only the first backslash and backtick was being escaped. This broke `update` and `set (merge)` calls when a field path contained multiple backslashes.

`replaceAll` is an alternative here, but I think a global regex has better compatibility with older versions of Node.
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, and the updated unit tests!

@dconeybe dconeybe added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Dec 13, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 13, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 13, 2024
@MarkDuckworth MarkDuckworth changed the base branch from main to community/albertnis/fix-escape December 13, 2024 18:54
@MarkDuckworth MarkDuckworth merged commit b8cbf9a into googleapis:community/albertnis/fix-escape Dec 13, 2024
13 checks passed
dconeybe pushed a commit that referenced this pull request Dec 17, 2024
…cks (#2259) (#2261)

Co-authored-by: Albert Nisbet <4309984+albertnis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FieldPath only escapes the first \ and '`', resulting in INVALID_ARGUMENT response
4 participants