Skip to content

escape tildes at the start of a line in commonmark renderer - #668

Open
zayeem06 wants to merge 1 commit into
commonmark:masterfrom
zayeem06:tilde-line-start-escape
Open

zayeem06 wants to merge 1 commit into
commonmark:masterfrom
zayeem06:tilde-line-start-escape

Conversation

@zayeem06

Copy link
Copy Markdown
Contributor

outc in src/commonmark.c escapes -, + and = at the start of a line of text but not ~, so a paragraph line such as \~~~ (or one after a soft break) is written as a bare ~~~ that opens a code fence when the output is parsed again. That fence swallows the following blocks until any later ~~~ line, including one inside a backtick code block, so \~~~ followed by a code block containing ~~~ and <script>alert(1)</script> comes back from cmark -t commonmark as a live HTML block. The fix adds ~ to the line-start escape set so it is written as \~, with an api_test case under render_commonmark; it is separate from the wrapping case in #646, and reviewers may want to confirm the spec examples still round-trip with the same 6 mismatches as master (they do here).

outc escaped -, + and = at the start of a line of text but not ~, so a
text line beginning with ~~~ was written unescaped and opened a code
fence when the output was parsed again. A later ~~~ line, even one
inside a backtick code block, then closed that fence and the rest of
the code block was parsed as Markdown, turning e.g. a <script> line in
a code block into a raw HTML block.
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