Preserve a trailing unterminated escape sequence in unescape() (#84)#85
Open
CedricConday wants to merge 1 commit into
Open
Preserve a trailing unterminated escape sequence in unescape() (#84)#85CedricConday wants to merge 1 commit into
CedricConday wants to merge 1 commit into
Conversation
…aulett#84) When a field ended in the middle of an escape sequence (e.g. a trailing lone escape character as in '\E\R\'), the loop left the opening escape character and any collected characters unflushed, so they were silently dropped: unescape('\E\R\') returned '\R' instead of '\R\'. Flush the unterminated sequence literally after the loop, since it cannot be decoded. Closes johnpaulett#84.
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.
Closes #84
returns
\Rbut should return\R\:\E\decodes to a literal\,R\— anRfollowed by a trailing lone escape character.Cause
unescape()walks the field character by character. A trailing escape character setsin_seq = Truebut the sequence never closes, so at the end of the loop the opening escape character (and any characters collected after it) are left unflushed and silently dropped.Fix
After the loop, if we're still mid-sequence, flush the unterminated sequence literally — it can't be decoded, so the original characters are preserved instead of lost.
Tests
Added to
test_unescape:These fail on
mainand pass with the fix. Full suite stays green (100 tests); existing escape-sequence cases (separators, highlight, hex, app-overrides) are unaffected.AI disclosure: prepared with AI assistance (Claude Code), human-reviewed and verified before opening.