Conversation
The spec forbids U+0000–1F and U+007F in unbracketed destinations. The handwritten scanner only stopped on whitespace, so [a](\x01) became a link. Fixes commonmark#127
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.
Summary
The handwritten unbracketed destination scanner stops on
c <= 0x20 || c === 0x7F(the old whitespace set plus the remaining controls and DEL). It only stopped on whitespace (space/ tab / LF / VT / FF / CR), so[a](\x01)became<a href="%01">.Robin Stocker reported this against spec 0.28; the copy of spec 0.31.2 in this repo still states that unbracketed destinations must not contain ASCII control characters (
U+0000–1ForU+007F) or space. Inline links, images, and reference definitions all go through this scanner.Angle-bracket destinations (
<...>) are a different production and still allow controls other than NUL/line endings. NUL is still replaced with U+FFFD before parsing, so[a](\x00)remains a link to the replacement character.Stop (do not
return null) on space/control in the unbracketed form only. Alternative: fail the destination immediately, and/or also reject controls inside<...>.Space in this loop already stops rather than failing. That matches the reporter's "doesn't stop" and markdown-it's destination helper. Can switch to failing closed on the first control, or to rejecting controls inside
<...>.Fixes #127
Test plan
npm test(748 passed, including the five new Link destination parsing accepts control characters (but should not) #127 cases)%01output comes back) and pass with it restoredlib/inlines.jsandtest/test.jsmake benchbefore/after (not run here; the new check replaces a per-character regex)