Skip to content

Fix unescape of escaped literals in TEXT values and parameter values - #13

Merged
RobSlgm merged 2 commits into
closureOSS:mainfrom
binggao1230:fix-unescape-overlapping-tokens
Aug 31, 2026
Merged

RobSlgm merged 2 commits into
closureOSS:mainfrom
binggao1230:fix-unescape-overlapping-tokens

Conversation

@binggao1230

Copy link
Copy Markdown
Contributor

Both un-escapers decoded with sequential global Replace calls whose tokens overlap the escaped-escape token:

  • UnescapeText: \\n (an escaped literal backslash + n, RFC 5545) collapsed to \n and then decoded to a newline.
  • ParameterExtensions.Unescape: ^^n / ^^' (escaped caret + n / apostrophe, RFC 6868) decoded to ^+newline / ^" instead of ^n / ^'.

Replaced the sequential replaces with a single forward scan that consumes each escape token once; undefined escapes keep both characters, as before.

Tests cover the affected round-trips, each escape token's decode, and an exhaustive round-trip over the escape surface (all 370 tests pass).

Separate commit: refresh VSyntaxReader/packages.lock.json — nuget.org republished Microsoft.NET.ILLink.Tasks 10.0.10, so the pinned hash is stale and dotnet restore --locked-mode fails with NU1403 on a fresh machine.

UnescapeText and ParameterExtensions.Unescape used sequential string.Replace
calls whose tokens overlap the escaped-escape token, so an escaped literal
decoded to the wrong character:

- \\n (literal backslash + n) became a newline instead of \n
- ^^n / ^^' (escaped caret + n / ') became ^ + newline / ^" instead of ^n / ^'

Replace the sequential replaces with one forward scan that consumes each
escape token once; undefined escapes keep both characters.
nuget.org republished Microsoft.NET.ILLink.Tasks 10.0.10, so the pinned
contentHash in VSyntaxReader/packages.lock.json no longer matches the
downloaded package and 'dotnet restore --locked-mode' fails with NU1403 on
a fresh machine. Regenerated by dotnet restore.
@RobSlgm
RobSlgm merged commit 384a80a into closureOSS:main Aug 31, 2026
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