mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
tpl/tplimpl: Use plain text for image render hook alt attribute
Co-authored-by: Heracles <email@heracl.es>
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
dde9d9d544
commit
8af04745fb
@@ -246,9 +246,10 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
|
|||||||
func TestRenderHooksDefaultEscape(t *testing.T) {
|
func TestRenderHooksDefaultEscape(t *testing.T) {
|
||||||
files := `
|
files := `
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
[markup.goldmark.renderHooks]
|
[markup.goldmark.extensions.typographer]
|
||||||
|
disable = true
|
||||||
[markup.goldmark.renderHooks.image]
|
[markup.goldmark.renderHooks.image]
|
||||||
enableDefault = ENABLE
|
enableDefault = ENABLE
|
||||||
[markup.goldmark.renderHooks.link]
|
[markup.goldmark.renderHooks.link]
|
||||||
enableDefault = ENABLE
|
enableDefault = ENABLE
|
||||||
[markup.goldmark.parser]
|
[markup.goldmark.parser]
|
||||||
@@ -256,6 +257,7 @@ wrapStandAloneImageWithinParagraph = false
|
|||||||
[markup.goldmark.parser.attribute]
|
[markup.goldmark.parser.attribute]
|
||||||
block = true
|
block = true
|
||||||
title = true
|
title = true
|
||||||
|
|
||||||
-- content/_index.md --
|
-- content/_index.md --
|
||||||
---
|
---
|
||||||
title: "Home"
|
title: "Home"
|
||||||
@@ -279,7 +281,7 @@ Image: 
|
|||||||
if enabled {
|
if enabled {
|
||||||
b.AssertFileContent("public/index.html",
|
b.AssertFileContent("public/index.html",
|
||||||
"Link: <a href=\"/destination-%22%3C%3E\" title=\"title-"<>&\">text-"<>&</a>",
|
"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>",
|
"><script>",
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<img src="{{ $src }}" alt="{{ .Text }}"
|
<img src="{{ $src }}" alt="{{ .PlainText }}"
|
||||||
{{- with .Title }} title="{{ . }}" {{- end -}}
|
{{- with .Title }} title="{{ . }}" {{- end -}}
|
||||||
{{- range $k, $v := .Attributes -}}
|
{{- range $k, $v := .Attributes -}}
|
||||||
{{- if $v -}}
|
{{- if $v -}}
|
||||||
|
@@ -146,6 +146,8 @@ func TestEmbeddedImageRenderHook(t *testing.T) {
|
|||||||
-- config.toml --
|
-- config.toml --
|
||||||
baseURL = 'https://example.org/dir/'
|
baseURL = 'https://example.org/dir/'
|
||||||
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
||||||
|
[markup.goldmark.extensions.typographer]
|
||||||
|
disable = true
|
||||||
[markup.goldmark.parser]
|
[markup.goldmark.parser]
|
||||||
wrapStandAloneImageWithinParagraph = false
|
wrapStandAloneImageWithinParagraph = false
|
||||||
[markup.goldmark.parser.attribute]
|
[markup.goldmark.parser.attribute]
|
||||||
@@ -174,7 +176,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
|
|||||||
b.AssertFileContent("public/p1/index.html",
|
b.AssertFileContent("public/p1/index.html",
|
||||||
`<img src="" alt="">`,
|
`<img src="" alt="">`,
|
||||||
`<img src="/dir/p1/pixel.png" alt="alt1">`,
|
`<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?a=b&c=d#fragment" alt="alt3">`,
|
||||||
`<img src="/dir/p1/pixel.png" alt="alt4">`,
|
`<img src="/dir/p1/pixel.png" alt="alt4">`,
|
||||||
)
|
)
|
||||||
@@ -185,7 +187,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
|
|||||||
b.AssertFileContent("public/p1/index.html",
|
b.AssertFileContent("public/p1/index.html",
|
||||||
`<img src="" alt="">`,
|
`<img src="" alt="">`,
|
||||||
`<img src="/dir/p1/pixel.png" alt="alt1">`,
|
`<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?a=b&c=d#fragment" alt="alt3" class="foo" id="bar">`,
|
||||||
`<img src="/dir/p1/pixel.png" alt="alt4" id=""><script>alert()</script>">`,
|
`<img src="/dir/p1/pixel.png" alt="alt4" id=""><script>alert()</script>">`,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user