From e22b3f54c3d8ce6567c21c63beab0b03cf7983ea Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Mon, 22 Apr 2019 15:26:36 +0100 Subject: tpl: Fix internal templates usage of safeHTMLAttr The `safeHTMLAttr` function operates on a full attribute definition, not just within the attribute value. Docs: https://gohugo.io/functions/safehtmlattr/ For `opengraph.html`, run the whole `content` HTML attribute through `safeHTMLAttr`. That will preserve `+` signs in formatted dates. For `vimeo_simple.html`, `safeHTMLAttr` was in the context of an attribute value, thus having no effect. In this case we could replace it with `safeURL`, but since the code is coming from an API it is safer to just let Go's template engine sanitize the value as it already does with `provider_url`. Fixes #5236 (no need to change Go upstream) Related to #5246 --- tpl/tplimpl/embedded/templates.autogen.go | 11 ++++++----- tpl/tplimpl/embedded/templates/opengraph.html | 9 +++++---- tpl/tplimpl/embedded/templates/shortcodes/vimeo_simple.html | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'tpl') diff --git a/tpl/tplimpl/embedded/templates.autogen.go b/tpl/tplimpl/embedded/templates.autogen.go index 164f3b927..58d0b2799 100644 --- a/tpl/tplimpl/embedded/templates.autogen.go +++ b/tpl/tplimpl/embedded/templates.autogen.go @@ -187,14 +187,15 @@ if (!doNotTrack) { {{ end }}{{ end }} +{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} {{- if .IsPage }} -{{- if not .PublishDate.IsZero }} -{{ else if not .Date.IsZero }} +{{- if not .PublishDate.IsZero }} +{{ else if not .Date.IsZero }} {{ end }} -{{- if not .Lastmod.IsZero }}{{ end }} +{{- if not .Lastmod.IsZero }}{{ end }} {{- else }} {{- if not .Date.IsZero }} - + {{- end }} {{- end }}{{/* .IsPage */}} @@ -482,7 +483,7 @@ if (!doNotTrack) { {{ $secondClass := "s_video_simple" }}
{{- with $item }} - + {{ $thumb := .thumbnail_url }} {{ $original := $thumb | replaceRE "(_.*\\.)" "." }} {{ .title }} diff --git a/tpl/tplimpl/embedded/templates/opengraph.html b/tpl/tplimpl/embedded/templates/opengraph.html index 8e4fb8115..de2d2fddf 100644 --- a/tpl/tplimpl/embedded/templates/opengraph.html +++ b/tpl/tplimpl/embedded/templates/opengraph.html @@ -6,14 +6,15 @@ {{ end }}{{ end }} +{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} {{- if .IsPage }} -{{- if not .PublishDate.IsZero }} -{{ else if not .Date.IsZero }} +{{- if not .PublishDate.IsZero }} +{{ else if not .Date.IsZero }} {{ end }} -{{- if not .Lastmod.IsZero }}{{ end }} +{{- if not .Lastmod.IsZero }}{{ end }} {{- else }} {{- if not .Date.IsZero }} - + {{- end }} {{- end }}{{/* .IsPage */}} diff --git a/tpl/tplimpl/embedded/templates/shortcodes/vimeo_simple.html b/tpl/tplimpl/embedded/templates/shortcodes/vimeo_simple.html index dac4aaa03..50699ecd4 100644 --- a/tpl/tplimpl/embedded/templates/shortcodes/vimeo_simple.html +++ b/tpl/tplimpl/embedded/templates/shortcodes/vimeo_simple.html @@ -10,7 +10,7 @@ {{ $secondClass := "s_video_simple" }}