Repository navigation
decode entities and backslash escapes in one pass - #650
Merged
Merged
Conversation
Link destinations, link titles and info strings were entity-decoded first and backslash-unescaped afterwards, so an escaped `&` still started an entity (`[a](\©)` gave href `%5C%C2%A9`) and an entity decoding to `\` escaped the next character (`[b](&commonmark#92;&commonmark#42;)` gave href `*`). Decode both in a single pass, as the spec and commonmark.js do.
Contributor
|
houdini_unescape_html and houdini_unescape_html_f also have no callers after the patch, I think. All unused internal functions should be removed, maybe in a separate commit. |
Member
|
Thank you! Comments welcome on #652 which removes the unused houdini functions. |
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.
cmark_clean_url and cmark_clean_title in src/inlines.c, and the info string handling in finalize in src/blocks.c, decode entity references first and then strip backslash escapes from the result, so these strings are decoded twice:
[a](\©)gives href%5C%C2%A9instead of©, and[b](\*)gives href*instead of%5C*, which disagrees with the spec and with commonmark.js 0.31.2. The new cmark_unescape_string handles both kinds of escape in one left-to-right pass and replaces the two-step decode at all three sites, which also covers reference definitions since they go through the same two functions; the info string is still trimmed after decoding, as before. Worth checking: regression cases in test/regression.txt fail before the change and pass after, the spec and roundtrip suites stay green, and cmark_strbuf_unescape no longer has callers but I left it in place to keep the diff small.