electric-sql / electric-sql/electric
ArrayDecoder doesn't handle escaped backslashes in quoted PostgreSQL array elements
- Dominant language
- TypeScript
- Stars
- 10.4k
- Forks
- 375
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 18
Description
## Problem
The `decode_quoted_elem` function in `packages/elixir-client/lib/electric/client/ecto_adapter/array_decoder.ex` does not correctly handle escaped backslashes in quoted PostgreSQL array elements.
PostgreSQL array format requires `\\` (escaped backslash) in quoted strings to be decoded as a single backslash `\`, similar to how `\"` decodes to a quote. The current implementation only handles escaped quotes but treats backslashes as regular UTF8 characters, causing arrays containing literal backslashes to be decoded incorrectly—each `\\` results in two backslashes instead of one.
## Example
A PostgreSQL array like `{"a\\\\b"}` should decode to `["a\\b"]`, but currently decodes to `["a\\\\b"]`.
## Context
This issue was identified during review of PR #3699 but is pre-existing in the codebase and not introduced by that PR.
## References
- PR: https://github.com/electric-sql/electric/pull/3699
- Comment: https://github.com/electric-sql/electric/pull/3699#discussion_r2690724545
- Reported by: @robacourt
Contributor guide
Assessment
This issue has not been assessed yet.