Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect output starting with v1.4.2 #263

Closed
jmooring opened this issue Nov 11, 2021 · 1 comment
Closed

Incorrect output starting with v1.4.2 #263

jmooring opened this issue Nov 11, 2021 · 1 comment

Comments

@jmooring
Copy link
Contributor

Note that the input string contains \r\n. There are no problems when \n is used instead of \r\n.

func main() {
	md := goldmark.New(
		goldmark.WithRendererOptions(
			html.WithUnsafe(),
		),
	)

	input := "<a \r\nhref='link'>link</a>"

	var buf bytes.Buffer
	if err := md.Convert([]byte(input), &buf); err != nil {
		panic(err)
	}

	fmt.Println(buf.String())

}

Output with v1.4.1 (PASS):

<p><a 
href='link'>link</a></p>

Output with v1.4.2 and v1.4.3 (FAIL):

<p>&lt;a
href='link'&gt;link</a></p>
@hacdias
Copy link

hacdias commented Nov 12, 2021

Uff, I just tried to debug for an hour why there were some weird renderings. Here's another interesting example.

The HTML code to feed Goldmark:

<video autoplay muted loop>
    <source src="https://example.com/example.mp3" type="video/mp4">
    Your browser does not support the video tag.
</video>

As an input with \r\n as end line:

input := "<video autoplay muted loop>\r\n<source src=\"https://example.com/example.mp4\" type=\"video/mp4\">\r\nYour browser does not support the video tag.\r\n</video>"

The output will be:

<p><video autoplay muted loop></p>
<source src="https://example.com/example.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

Which is... broken.

@yuin yuin closed this as completed in 333aa4d Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants