mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
756 stars 138 forks source link

Unmatched closing parens inside www autolinks end the link #135

Closed dominickpastore closed 3 years ago

dominickpastore commented 3 years ago

It seems there is a mistake in a test case that is letting a bug through.

According to the GFM spec, unmatched closing parentheses fall outside www autolinks only when they do not fall inside the link. The same text is in test/permissive-www-autolinks.txt, but the corresponding test case doesn't actually have a mismatched parenthesis to test it. And, it turns out MD4C gets it wrong when the mismatched parenthesis is added:

Input:

www.google.com/search?q=(business))+ok

Expected output:

<p><a href="http://www.google.com/search?q=(business))+ok">www.google.com/search?q=(business))+ok</a></p>

Actual output:

<p><a href="http://www.google.com/search?q=(business)">www.google.com/search?q=(business)</a>)+ok</p>

(Note how )+ok is outside the link.)

mity commented 3 years ago

Will take a look at it. Thanks for reporting it.

dominickpastore commented 3 years ago

parentheses fall outside www autolinks only when they do not fall inside the link.

I just realized how silly that sentence sounds, but it sounds like you understood what I meant ;-)

mity commented 3 years ago

As long as people provide the blessed trinity Input, Expected Output and Actual Output in their reports, it's hard to misunderstand it :-)