From eb150c0c22749a11618a3e77ffc9ad0d58f11056 Mon Sep 17 00:00:00 2001 From: heiy <287789299@qq.com> Date: Mon, 8 Jun 2020 18:23:38 +0800 Subject: [PATCH] escape html tag --- cell.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cell.go b/cell.go index 064c432e..0912dc4a 100644 --- a/cell.go +++ b/cell.go @@ -13,6 +13,7 @@ import ( "encoding/xml" "errors" "fmt" + "html" "reflect" "strconv" "strings" @@ -620,7 +621,7 @@ func (f *File) SetCellRichText(sheet, cell string, runs []RichTextRun) error { sst := f.sharedStringsReader() textRuns := []xlsxR{} for _, textRun := range runs { - run := xlsxR{T: &xlsxT{Val: textRun.Text}} + run := xlsxR{T: &xlsxT{Val: html.EscapeString(textRun.Text)}} if strings.ContainsAny(textRun.Text, "\r\n ") { run.T.Space = xml.Attr{Name: xml.Name{Space: NameSpaceXML, Local: "space"}, Value: "preserve"} }