mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +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
@@ -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>">`,
|
||||
)
|
||||
|
Reference in New Issue
Block a user