Repository navigation
fix(d1): don't corrupt literal \n in export when a value also has a real newline - #8699
Jeremiah-D wants to merge 1 commit into
Conversation
…eal newline Signed-off-by: Jeremiah-D <235112616+Jeremiah-D@users.noreply.github.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
This pull request was not reviewed automatically because its author does not have write access to this repository. A maintainer with write access can start a review by commenting |
Fixes #8678.
Exporting a row whose value contains both a real newline and a literal
\ncorrupts the value:a<LF>b<\n>ccomes back asa<LF>b<LF>con import, becausequote()insrc/workerd/server/d1/d1.jsalways escapes newlines as\nwithout checking whether the value already contains that sequence.This ports the collision check from SQLite's
shell.c.in(same approach as Miniflare's fix in workers-sdk#15334):unusedEscape()tries\n, then\012, then(\n0),(\n1), … and takes the first escape not present in the value, with the same ladder on the CR side (\r,\015,(\r0), …).Verified with a standalone node harness (20 cases: the reporter's example now round-trips, golden rows match byte-for-byte, triple collisions escalate as expected) and against real SQLite end to end (4 rows, all identical after import). I couldn't run
wd-testlocally — no bazel here — so that's left for CI.