Skip to content

Conversation

@wtn
Copy link
Contributor

@wtn wtn commented Nov 14, 2025

Fixes data corruption when round-tripping strings containing backslashes or newlines in plain format.

Changes

  • Fix backslash escaping in CFString#quoted (output \\ instead of \)
  • Fix newline escaping in CFString#quoted (output \n instead of literal newline)
  • Fix regex in CFString#to_plain to use \A\z instead of ^$ for proper string anchoring
  • Add roundtrip tests for strings with backslashes and newlines

Background

Strings with special characters were corrupted during plain format serialization:

  • Backslashes were not properly escaped, causing "foo\bar" to become "foobar"
  • Newlines were output as literal characters instead of \n, breaking the parser
  • The regex check used line anchors instead of string anchors, causing multiline strings to bypass quoting

Co-authored-by: Claude <noreply@anthropic.com>
@ckruse ckruse merged commit 7f41962 into ckruse:master Nov 14, 2025
10 checks passed
@ckruse
Copy link
Owner

ckruse commented Nov 14, 2025

@wtn you did a lot of work. Thank you very much!

@wtn wtn deleted the roundtrip branch November 14, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants