jgm/commonmark-hs

[fuzz result] backslashing `&` entities doesn't escape them in link destinations

Closed this issue · 1 comments

Consider this markdown:

[link](\!)

The important part is the \! part, which the reference implementation translates to !, but commonmark-hs translates to !, seemingly ignoring the backslash.

Events from pulldown-cmark:

"[](*\\)\n" -> [
  Start(Paragraph)
    Start(Link { link_type: Inline, dest_url: Boxed("%2A%26%234%3B"), title: Borrowed(""), id: Borrowed("") })
    End(Link)
  End(Paragraph)
]

Events from pandoc:

"[](*\\)\n" -> [
  Start(Paragraph)
    Start(Link { link_type: Inline, dest_url: Boxed("%2A%04"), title: Inlined(InlineStr { inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], len: 0 }), id: Borrowed("") })
    End(Link)
  End(Paragraph)
]

Events from commonmark.js:

"[](*\\)\n" -> [
  Start(Paragraph)
    Start(Link { link_type: Inline, dest_url: Boxed("%2A%26%234%3B"), title: Inlined(InlineStr { inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], len: 0 }), id: Borrowed("") })
    End(Link)
  End(Paragraph)
]

AST from pandoc:

Pandoc {
    meta: {},
    blocks: [
        Para(
            [
                Link(
                    (
                        Attr(
                            "",
                            [],
                            [],
                        ),
                        [],
                        Target(
                            "*\u{4}",
                            "",
                        ),
                    ),
                ),
            ],
        ),
    ],
}
jgm commented

Instead of doing

target <- unEntity <$> pLinkDestination

in pInlineLink, we need to handle the entities as part of pLinkDestination.