fix: escape backslashes, quotes, and control chars in daemon TOML serialization#595
Open
SHudici wants to merge 1 commit into
Open
fix: escape backslashes, quotes, and control chars in daemon TOML serialization#595SHudici wants to merge 1 commit into
SHudici wants to merge 1 commit into
Conversation
…ialization The daemon config writer serializes TOML by hand and embedded string values verbatim. Windows paths (C:\Users\...) therefore produced invalid TOML that tomllib rejected on the next load, so the daemon could not round-trip its own config file. Escape backslashes and double quotes, plus the control-character range (U+0000-U+001F, U+007F) that the TOML spec forbids unescaped in basic strings — a pathological alias or session name must corrupt nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
The daemon config writer serializes TOML by hand. Repo paths are embedded verbatim, so any value containing backslashes or quotes produces invalid TOML. On Windows every path has backslashes (
C:\Users\...), which makestomllib.loadfail on the next read —crg daemoncannot round-trip its own config file.Fix
Escape backslashes and double quotes when writing string values, matching what
tomllibexpects to read back. Control characters (U+0000–U+001F, U+007F) are also escaped — named short escapes (\b \t \n \f \r) where TOML defines them,\uXXXXotherwise — since TOML basic strings may not contain them raw and a stray tab or newline in a path/name would corrupt the file the same way. No behavior change for values that never needed escaping.Testing
tests/test_daemon.pycover round-tripping Windows-style paths, quoted values, and control characters.One of a small series of PRs making the project fully usable on Windows contributor machines.
🤖 Generated with Claude Code