tpl/tplimpl: Use plain text for image render hook alt attribute
Co-authored-by: Heracles <email@heracl.es>
This commit is contained in:
parent
dde9d9d544
commit
8af04745fb
3 changed files with 10 additions and 6 deletions
|
@ -246,9 +246,10 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
|
|||
func TestRenderHooksDefaultEscape(t *testing.T) {
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
[markup.goldmark.renderHooks]
|
||||
[markup.goldmark.extensions.typographer]
|
||||
disable = true
|
||||
[markup.goldmark.renderHooks.image]
|
||||
enableDefault = ENABLE
|
||||
enableDefault = ENABLE
|
||||
[markup.goldmark.renderHooks.link]
|
||||
enableDefault = ENABLE
|
||||
[markup.goldmark.parser]
|
||||
|
@ -256,6 +257,7 @@ wrapStandAloneImageWithinParagraph = false
|
|||
[markup.goldmark.parser.attribute]
|
||||
block = true
|
||||
title = true
|
||||
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: "Home"
|
||||
|
@ -279,7 +281,7 @@ Image: 
|
|||
if enabled {
|
||||
b.AssertFileContent("public/index.html",
|
||||
"Link: <a href=\"/destination-%22%3C%3E\" title=\"title-"<>&\">text-"<>&</a>",
|
||||
"img src=\"/destination-%22%3C%3E\" alt=\"alt-"<>&\" title=\"title-"<>&\">",
|
||||
"img src=\"/destination-%22%3C%3E\" alt=\"alt-"<>&\" title=\"title-"<>&\">",
|
||||
"><script>",
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<img src="{{ $src }}" alt="{{ .Text }}"
|
||||
<img src="{{ $src }}" alt="{{ .PlainText }}"
|
||||
{{- with .Title }} title="{{ . }}" {{- end -}}
|
||||
{{- range $k, $v := .Attributes -}}
|
||||
{{- if $v -}}
|
||||
|
|
|
@ -146,6 +146,8 @@ func TestEmbeddedImageRenderHook(t *testing.T) {
|
|||
-- config.toml --
|
||||
baseURL = 'https://example.org/dir/'
|
||||
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
||||
[markup.goldmark.extensions.typographer]
|
||||
disable = true
|
||||
[markup.goldmark.parser]
|
||||
wrapStandAloneImageWithinParagraph = false
|
||||
[markup.goldmark.parser.attribute]
|
||||
|
@ -174,7 +176,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
|
|||
b.AssertFileContent("public/p1/index.html",
|
||||
`<img src="" alt="">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt1">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt2-&<>’" title="&<>'">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt2-&<>'" title="&<>'">`,
|
||||
`<img src="/dir/p1/pixel.png?a=b&c=d#fragment" alt="alt3">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt4">`,
|
||||
)
|
||||
|
@ -185,7 +187,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
|
|||
b.AssertFileContent("public/p1/index.html",
|
||||
`<img src="" alt="">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt1">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt2-&<>’" title="&<>'">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt2-&<>'" title="&<>'">`,
|
||||
`<img src="/dir/p1/pixel.png?a=b&c=d#fragment" alt="alt3" class="foo" id="bar">`,
|
||||
`<img src="/dir/p1/pixel.png" alt="alt4" id=""><script>alert()</script>">`,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue