fix: title in xml not escape

This commit is contained in:
henry.chen
2026-01-04 09:54:25 +08:00
parent 0fdd8e0bd6
commit 14b4534c1e
2 changed files with 5 additions and 3 deletions

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{.Title}}</title>
<title>{{xmlescape .Title}}</title>
<link>https://{{.Host}}</link>
<description>{{.SubTitle}}</description>
<description>{{xmlescape .SubTitle}}</description>
<atom:link href="https://{{.Host}}/rss.html" rel="self" />
<atom:link href="{{.FeedrURL}}" rel="hub" />
<language>zh-CN</language>
<lastBuildDate>{{.BuildDate}}</lastBuildDate>
{{range .Articles}}
<item>
<title>{{.Title}}</title>
<title>{{xmlescape .Title}}</title>
<link>https://{{$.Host}}/post/{{.Slug}}.html</link>
<comments>https://{{$.Host}}/post/{{.Slug}}.html#comments</comments>
<guid>https://{{$.Host}}/post/{{.Slug}}.html</guid>

View File

@@ -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