Skip to content

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

Open
gaoflow wants to merge 2 commits into
closureOSS:mainfrom
gaoflow:fix-unescape-overlapping-tokens
Open

Fix unescape of escaped literals in TEXT values and parameter values#13
gaoflow wants to merge 2 commits into
closureOSS:mainfrom
gaoflow:fix-unescape-overlapping-tokens

Conversation

@gaoflow

@gaoflow gaoflow commented Jul 31, 2026

Copy link
Copy Markdown

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.

gaoflow added 2 commits July 31, 2026 21:07
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.
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.

1 participant