Repository navigation
Escape a lone surrogate in a quoted string literal [patch] - #139
Merged
Merged
Conversation
QuoteStringLiteral copied an unpaired surrogate into the literal raw. It has no UTF-8 encoding, so saving the generated file either threw or silently replaced the character with U+FFFD, changing the constant's value. A surrogate that is not half of a valid pair now takes a \uXXXX escape; valid pairs are still written as they are. Fixes #130 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014h6btvAuM1Ew7cCFSpuFWc
|
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.



Fixes #130
What changed
TemplateRendering.QuoteStringLiteralnow writes any surrogate that is not half of a valid high/low pair as a\uXXXXescape. A valid pair is still written raw, so readable text such as emoji stays as it is. Before this change, an unpaired surrogate went into the generated source unescaped. It has no UTF-8 encoding, soFile.WriteAllTextthrew anEncoderFallbackException, or a replacing encoder silently turned it into U+FFFD and the constant's value changed.Tests
TemplateTests.ParameterEscapesALoneSurrogateInAQuotedDefaultValue.\uDE00\uD83D), and a valid pair.DataRow, because attribute arguments are stored as UTF-8 and cannot carry a lone surrogate.🤖 Generated with Claude Code
https://claude.ai/code/session_014h6btvAuM1Ew7cCFSpuFWc
Generated by Claude Code