diff --git a/markup/goldmark/goldmark_integration_test.go b/markup/goldmark/goldmark_integration_test.go index b1c182034..c088201b3 100644 --- a/markup/goldmark/goldmark_integration_test.go +++ b/markup/goldmark/goldmark_integration_test.go @@ -1035,3 +1035,33 @@ foo[^1] and bar[^2] "

foo1 and bar2

\n
\n
\n
    \n
  1. \n

    footnote one back

    \n
  2. \n
  3. \n

    footnote two back

    \n
  4. \n
\n
", ) } + +func TestRenderLinkDefaultDangerous(t *testing.T) { + t.Parallel() + + /* + Content:

Link: Click me + AutoLink: javascript:alert(1) + Image: alt

+ */ + + files := ` +-- content/p1.md -- +--- +title: "p1" +--- +Link: [Click me](javascript:alert(1)) +AutoLink: +Image: ![alt](javascript:alert(3)) +-- layouts/all.html -- +Content: {{ .Content }} +` + + b := hugolib.Test(t, files) + + b.AssertFileContent("public/p1/index.html", + `! alert(1)"`, + `! href="javascript:alert(2)"`, + `! alert(3)"`, + ) +} diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go index 1e91f7ab1..418358054 100644 --- a/markup/goldmark/render_hooks.go +++ b/markup/goldmark/render_hooks.go @@ -230,8 +230,9 @@ func (r *hookedRenderer) renderImageDefault(w util.BufWriter, source []byte, nod } n := node.(*ast.Image) _, _ = w.WriteString("