blackfriday icon indicating copy to clipboard operation
blackfriday copied to clipboard

Incorrect Link Parsing

Open butuzov opened this issue 4 years ago • 0 comments

  • Originally found as a bug in kubernetes/website#16640
  • Originally found as a bug in Hugo gohugoio/hugo#6438

Tested v1 and v2. Both affected.

Short Description

Whitespace(s) or Tab before parentheses (()) opening is ignored if it comes after brackets ([]).

Long Description

In the text blocks that "like" a link, are treated as a link, even if they are a links of a different kind.


Reproducible Example

package main

import (
	"fmt"

	"gopkg.in/russross/blackfriday.v2"
)

var input = `
* [example_org link]
* [example_net link](https://example.net)
* [example_com link] (hey, there is space before parenthese, ignoge me please)


[example_org link]: https://example.org
[example_com link]: https://example.com
`

func main() {
	output := string(blackfriday.Run([]byte(input)))
	fmt.Println(output)
}

Expected Output

<ul>
<li><a href="https://example.org">example_org link</a></li>
<li><a href="https://example.net">example_net link</a></li>
<li><a href="https://example.com">example_com link</a> (hey, there is space before parenthese, ignoge me please)</li>
</ul>

Actual Output

<ul>
<li><a href="https://example.org">example_org link</a></li>
<li><a href="https://example.net">example_net link</a></li>
<li><a href="hey, there is space before parenthese, ignoge me please">example_com link</a></li>
</ul>

butuzov avatar Nov 11 '19 12:11 butuzov