From 14b4534c1e034684b19808168ad0fbf5464e18ef Mon Sep 17 00:00:00 2001 From: "henry.chen" Date: Sun, 4 Jan 2026 09:54:25 +0800 Subject: [PATCH] fix: title in xml not escape --- cmd/eiblog/etc/xml/feedTpl.xml | 6 +++--- tools/tmplfunc.go | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/eiblog/etc/xml/feedTpl.xml b/cmd/eiblog/etc/xml/feedTpl.xml index f8c2f44..c20545a 100644 --- a/cmd/eiblog/etc/xml/feedTpl.xml +++ b/cmd/eiblog/etc/xml/feedTpl.xml @@ -1,16 +1,16 @@ - {{.Title}} + {{xmlescape .Title}} https://{{.Host}} - {{.SubTitle}} + {{xmlescape .SubTitle}} zh-CN {{.BuildDate}} {{range .Articles}} - {{.Title}} + {{xmlescape .Title}} https://{{$.Host}}/post/{{.Slug}}.html https://{{$.Host}}/post/{{.Slug}}.html#comments https://{{$.Host}}/post/{{.Slug}}.html diff --git a/tools/tmplfunc.go b/tools/tmplfunc.go index 2c137d6..aba586f 100644 --- a/tools/tmplfunc.go +++ b/tools/tmplfunc.go @@ -3,6 +3,7 @@ package tools import ( "encoding/base64" + "html" htmpl "html/template" "io" "log" @@ -26,6 +27,7 @@ func init() { TplFuncMap["isnotzero"] = IsNotZero TplFuncMap["getavatar"] = GetAvatar TplFuncMap["imgtonormal"] = ImgToNormal + TplFuncMap["xmlescape"] = html.EscapeString } // Str2html string to html