Conversation
JSON allows both characters raw inside strings, so diffr wrote them raw when a diffed file held one. Since Node 24, node:readline also ends a line at them, so a client reading diffr with readline got a record cut in two and failed to parse it (devdotfast/whiteboard#624). Records are now written through protocol::write_record, whose formatter escapes both as \u2028 and \u2029. The decoded text is unchanged. AI assistance: written with Claude Code; reviewed by the author. Agent-Session: 82924cb5-dcfa-42e4-abb0-ef40393249f8 Agent-Session: ea775653-fef8-47be-96ea-16815bdff22c Agent-Session: d72470a3-1f93-4201-8e6d-2730c798e92b
Python's str.splitlines() also ends a line at U+0085 (NEL), which serde_json writes raw. Every other character it splits on is a control character JSON already escapes, so records now survive splitlines() whole. AI assistance: written with Claude Code; reviewed by the author. Agent-Session: ea775653-fef8-47be-96ea-16815bdff22c Agent-Session: d72470a3-1f93-4201-8e6d-2730c798e92b
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.
JSON allows U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) raw inside strings, so diffr wrote them raw when a diffed file held one. Since Node 24,
node:readlinealso ends a line at these characters, so a client that reads diffr withreadlinegets a record cut in two and fails to parse it. Whiteboard's structural diff stops withMalformed diffr protocol record.(devdotfast/whiteboard#624).Python's
str.splitlines()has the same fault for U+0085 (NEL). Every other character it splits on is a control character that JSON already escapes.protocol::write_record. Its formatter writes the same compact JSON, and escapes the three characters as JSON\uXXXXescapes. The decoded text and its byte columns do not change.run.rswrites every record through it.\nonly and that the three characters are escaped.Testing
readlinereads 3 records that all parse.readlineorsplitlines()end a line at:splitlines()reads 3 records that all parse.cargo test,cargo clippy --all-targets(no new warnings) andcargo fmt --all -- --checkpassed locally.AI assistance: written with Claude Code; reviewed by the author.