Skip to content

Incorrect _ emphasis parsing #271

@notriddle

Description

@notriddle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions