Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect _ emphasis parsing #271

Closed
notriddle opened this issue Jun 20, 2023 · 1 comment · Fixed by #272
Closed

Incorrect _ emphasis parsing #271

notriddle opened this issue Jun 20, 2023 · 1 comment · Fixed by #272

Comments

@notriddle
Copy link
Contributor

Consider these three example snippets:

__!_!__
__!x!__
**!*!**

And the results they give in the commonmark dingus:

__!_!__

!x!

!*!

I think commonmark.js has a bug here, because the __ in __! is a left-flanking delimiter run. It is followed by a unicode punctuation character (!), and it is preceded by the beginning of the line (which is treated as whitespace).

More generally, it seems like, if the second example parses successfully, then the first one must also parse. The spec says that underscores are allowed in the middle of underscore-delimited strong emphasis (it wouldn't be allowed at the beginning or end of the emphasis span, but it's not).

This example was found by differential fuzzing with pulldown-cmark. Corresponding issue: pulldown-cmark/pulldown-cmark#660

@jgm
Copy link
Member

jgm commented Jun 20, 2023

With this input cmark gives:

<p>__!_!__
<strong>!x!</strong>
<strong>!*!</strong></p>

which I assume is the same as commonmark.js.

I agree that this looks like a bug in both cmark and commonmark.js (which use the same parsing algorithm).

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 a pull request may close this issue.

2 participants