Repository navigation
fix(db): escape backslashes in PostgreSQL text[] literals - #333
Merged
Merged
Conversation
BaaRai
approved these changes
Nov 18, 2026
BaaRai
left a comment
Owner
There was a problem hiding this comment.
The escape order is right: backslashes are doubled before quotes, so x\",evil stays a single element, matching marshalJSONBArray. The test pins the injection case. Thanks.
marshalStringArray quoted double quotes but not backslashes. In a Postgres array element a backslash escapes the following quote, so a value such as x\",evil,\"y could close the current element and inject another. Double backslashes first, matching marshalJSONBArray.
BaaRai
force-pushed
the
fix/pg-text-array-escape
branch
from
November 18, 2026 16:09
c09f34a to
7681bac
Compare
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.
marshalStringArraybuilds PostgreSQLtext[]literals and escaped"but not\. In array syntax a backslash still escapes the following quote, so a bound-domain / technology / record value ofx\",evil,\"ycan close the current element and inject another. It is still a bound parameter (no SQL statement injection), but metadata can be forged or the write can fail.Escape backslashes before quotes, the same order as
marshalJSONBArray.Tested:
go test ./db -run TestMarshalStringArraypass.