Go quotes like the other implementations: control characters only #5

Merged
merge-queue merged 1 commit from quote-controls-only into main 2026-11-26 12:43:39 -08:00
Owner

Work package: https://openproject.home.romaine.life/wp/AHT-204

Broken now: the same value made different lines in Go than in Rust, C, C# and JavaScript. Go quoted with strconv.Quote, which also escapes printable-looking characters (U+00A0 no-break space, U+200B zero-width space, U+2028 line separator, other non-printing characters); the other four write those as they are. Found by #4's comparison of the new implementations against Go on ~800,000 random inputs. Every parser read both forms back to the same value, so nothing was misread, but one standard means one byte form.

Changed

  • Go's quote (message and values): ", \, Go's short escapes, other control characters as \xNN / \uNNNN, everything else as it is: the rule Rust, C, C# and JavaScript already follow. strconv.Unquote still reads it.
  • Invalid UTF-8 in a Go value becomes U+FFFD before writing (the other languages' strings can't hold it).
  • testdata/golden.json gains a case pinning all of it (bare and quoted U+00A0/U+200B/U+2028, a C1 and a C0 control), which every implementation runs; Go adds a unit test for invalid UTF-8.

Checked: ci-check's 7 jobs pass: Go, Rust, C (cmake), C# (dotnet), JavaScript (web-app) all write and parse the new case identically.

🤖 Generated with Claude Code

Work package: https://openproject.home.romaine.life/wp/AHT-204 **Broken now:** the same value made different lines in Go than in Rust, C, C# and JavaScript. Go quoted with `strconv.Quote`, which also escapes printable-looking characters (U+00A0 no-break space, U+200B zero-width space, U+2028 line separator, other non-printing characters); the other four write those as they are. Found by #4's comparison of the new implementations against Go on ~800,000 random inputs. Every parser read both forms back to the same value, so nothing was misread, but one standard means one byte form. **Changed** - Go's `quote` (message and values): `"`, `\`, Go's short escapes, other control characters as `\xNN` / `\uNNNN`, everything else as it is: the rule Rust, C, C# and JavaScript already follow. `strconv.Unquote` still reads it. - Invalid UTF-8 in a Go value becomes U+FFFD before writing (the other languages' strings can't hold it). - `testdata/golden.json` gains a case pinning all of it (bare and quoted U+00A0/U+200B/U+2028, a C1 and a C0 control), which every implementation runs; Go adds a unit test for invalid UTF-8. **Checked:** ci-check's 7 jobs pass: Go, Rust, C (cmake), C# (dotnet), JavaScript (web-app) all write and parse the new case identically. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Go quotes like the other implementations: control characters only (AHT-204)
All checks were successful
Suite go / check-services (pull_request) Has been skipped
Suite release / check-package (pull_request) Has been skipped
Suite release / build (none, ubuntu-latest) (ubuntu-latest, none) (pull_request) Has been skipped
Suite rust / check-audit (pull_request) Has been skipped
Suite release / check-build (none, ubuntu-latest) (ubuntu-latest, none) (pull_request) Has been skipped
Suite release / reused-checks (pull_request) Has been skipped
Suite release / home-sync (pull_request) Has been skipped
Suite default / check-rules (pull_request) Successful in 8s
Suite cmake / check-test-windows (pull_request) Successful in 54s
Suite rust / check-test-windows (pull_request) Successful in 36s
Suite release / reserve (pull_request) Has been skipped
Suite go / check-test-linux (pull_request) Has been skipped
Suite default / check-fetches (pull_request) Has been skipped
Suite release / dispatch (pull_request) Has been skipped
Suite release / deploy-image (pull_request) Has been skipped
Suite cmake / check-test-linux (pull_request) Successful in 8s
Suite rust / reused-checks (pull_request) Successful in 5s
Suite go / check-test-windows (pull_request) Successful in 34s
Suite release / module (pull_request) Has been skipped
Suite go / check-format (pull_request) Successful in 9s
Suite web-app / check-test (.) (pull_request) Successful in 12s
Suite dotnet / check-test-windows (pull_request) Successful in 54s
Suite release / finalize (pull_request) Has been skipped
Suite release / publish (pull_request) Has been skipped
Suite cmake / reused-checks (pull_request) Successful in 7s
Suite dotnet / reused-checks (pull_request) Successful in 4s
Suite go / reused-checks (pull_request) Successful in 4s
merge-queue landed on main
Suite default / reused-checks (pull_request) Successful in 7s
Suite web-app / reused-checks (pull_request) Successful in 7s
0d4dddf032
strconv.Quote also escaped printable-looking characters (U+00A0, U+200B,
U+2028) that Rust, C, C# and JavaScript write as they are, so the same
value made different lines. Go now uses the shared quoting, invalid UTF-8
in a value becomes U+FFFD, and golden.json pins both for every
implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
merge-queue deleted branch quote-controls-only 2026-11-26 12:43:39 -08:00
Sign in to join this conversation.
No reviewers
No labels
queue
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/logline!5
No description provided.