russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.42k stars 598 forks source link

Problem with an image link with a title containing parentheses #588

Open nobu-k opened 4 years ago

nobu-k commented 4 years ago

Image links containing parentheses like ![foo with a title](/bar/ "title with ()") aren't parsed correctly. FYI, I've added the following test case in TestInlineLink in inline_test.go to see how it fails:

"![foo with a title](/bar/ \"title with ()\"  )\n",
"<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title with ()\" /></p>\n",

The result of go test was

--- FAIL: TestInlineLink (0.41s)
    helpers_test.go:81: 
        Input   ["![foo with a title](/bar/ \"title with ()\"  )\n"]
        Expected["<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title with ()\" /></p>\n"]
        Actual  ["<p><img src=\"/bar/ &quot;title with (\" alt=\"foo with a title\" />&quot;  )</p>\n"]
    helpers_test.go:81: 
        Input   ["![foo with a title](/bar/ \"title with ()\"  )\n"]
        Expected["<p><img src=\"http://localhost/bar/\" alt=\"foo with a title\" title=\"title with ()\" /></p>\n"]
        Actual  ["<p><img src=\"http://localhost/bar/ &quot;title with (\" alt=\"foo with a title\" />&quot;  )</p>\n"]
    helpers_test.go:81: 
        Input   ["![foo with a title](/bar/ \"title with ()\"  )\n"]
        Expected["<p><img src=\"http://localhost/bar/\" alt=\"foo with a title\" title=\"title with ()\" /></p>\n"]
        Actual  ["<p><img src=\"http://localhost/bar/ &quot;title with (\" alt=\"foo with a title\" />&quot;  )</p>\n"]
FAIL
exit status 1
FAIL    github.com/russross/blackfriday/v2      8.699s

GitHub parses this as expected: foo with a title