fix(postgrest): escape embedded quotes and backslashes in in()/notIn() filter values#2489
Open
kazuki-netizen wants to merge 1 commit into
Open
fix(postgrest): escape embedded quotes and backslashes in in()/notIn() filter values#2489kazuki-netizen wants to merge 1 commit into
kazuki-netizen wants to merge 1 commit into
Conversation
…) filter values Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
.in()and.notIn()wrap values containing PostgREST reserved characters (,()) in double quotes, but do not escape a"or\inside the value. A value likea"b,ccurrently serializes toin.("a"b,c"), whose stray quote breaks PostgREST's list parsing.Fix
Escape
\→\\and"→\"(backslash first) before wrapping. This matches PostgREST's quoted-element parser (pQuotedValueinApiRequest/QueryParams.hs, where a backslash escapes the following character inside quotes; see also PostgREST/postgrest#1938 and supabase/postgrest-js#164). The shared logic is extracted into a smallformatInFilterValue()helper used by bothin()andnotIn(). Simple values are still emitted unquoted — no behavior change for existing callers.Test
Adds
test/in-filter-escaping.test.tswith URL-level assertions (mock fetch, no live server) covering reserved-char quoting, embedded-quote escaping, backslash escaping, simple-value passthrough, andnotInparity. All 6 pass;tsc --noEmit, ESLint, and Prettier are clean on the touched files.🤖 Generated with Claude Code