Skip to content

[fuzz result] unbalanced parens are parsed as a link title #840

@notriddle

Description

@notriddle

This markdown should not produce a link:

[link]: test (()

[link]

The commonmark.js dingus does this right. As the spec sayeth:

https://spec.commonmark.org/0.30/#link-reference-definitions

A link reference definition consists of a link label, optionally preceded by up to three spaces of indentation, followed by a colon (:), optional spaces or tabs (including up to one line ending), a link destination, optional spaces or tabs (including up to one line ending), and an optional link title, which if it is present must be separated from the link destination by spaces or tabs. No further character may occur.

https://spec.commonmark.org/0.30/#link-title

A link title consists of either

  • a sequence of zero or more characters between straight double-quote characters ("), including a " character only if it is backslash-escaped, or
  • a sequence of zero or more characters between straight single-quote characters ('), including a ' character only if it is backslash-escaped, or
  • a sequence of zero or more characters between matching parentheses ((...)), including a ( or ) character only if it is backslash-escaped.
Details
"[+]:\\\n(()" -> [
]

Events from commonmark.js:

"[+]:\\\n(()" -> [
  Start(Paragraph)
    Text(Boxed("(()"))
  End(Paragraph)
]

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