Repository navigation
Don't treat an escaped backslash as the start of another escape in HtmlHelper.Unescape - #967
Merged
xoofx merged 3 commits intoOct 23, 2026
Conversation
…mlHelper.Unescape Co-Authored-By: Claude Opus 5.5 <[email protected]>
A backslash-escaped & is a literal character, so it must not start an entity reference (CommonMark: '\ö' is not an entity). This matches commonmark.js. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Markdig.Tests/TestFencedCodeBlocks.cs
Owner
|
Thank you @HuzaifaChaudary for tracking this one down! 🙏 The fix for the escaped backslash was right. I pushed one small follow-up before merging: an escaped Squash-merged. Reviewed by CodeAlta + Opus 5.5/Low |
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.
HtmlHelper.Unescapekeeps the character after a backslash by movinglastPosto it , butsearchPosstayed on that character , so an escaped backslash was scanned again as the start of a new escape . a fenced code info string with\\before a punctuation character lost the backslash :~~~ \\*language-\*language-*language-\*~~~ x\\_language-x\_language-x_language-x\_~~~ \\alanguage-\aafter an escape the scan now moves past the escaped character . the one exception is
&: cmark unescapes backslashes before entities , so\&gives&in both today , and that stays as it is .UnescapewithremoveBackSlash: trueis only used for the fenced code info string and arguments and the auto identifier link , link urls and titles passremoveBackSlash: falseand are not affected .found by rendering 19200 random documents with Markdig and cmark-gfm in CommonMark mode : 8 differences fixed , none new . three cases are added to
TestInfoAndArguments, the two with an escaped backslash fail before the change , the\&one pins the current behavior .dotnet test -c Release: 7375 passed on net8.0 and net10.0 .