@@ -6,7 +6,6 @@ package templates
66
77import (
88 "fmt"
9- "html"
109 "html/template"
1110 "net/url"
1211 "strconv"
@@ -38,9 +37,7 @@ func NewFuncMap() template.FuncMap {
3837 "dict" : dict , // it's lowercase because this name has been widely used. Our other functions should have uppercase names.
3938 "Iif" : iif ,
4039 "Eval" : evalTokens ,
41- "SafeHTML" : safeHTML ,
4240 "HTMLFormat" : htmlFormat ,
43- "HTMLEscape" : htmlEscape ,
4441 "QueryEscape" : queryEscape ,
4542 "QueryBuild" : QueryBuild ,
4643 "JSEscape" : jsEscapeSafe ,
@@ -165,32 +162,11 @@ func NewFuncMap() template.FuncMap {
165162 }
166163}
167164
168- // safeHTML render raw as HTML
169- func safeHTML (s any ) template.HTML {
170- switch v := s .(type ) {
171- case string :
172- return template .HTML (v )
173- case template.HTML :
174- return v
175- }
176- panic (fmt .Sprintf ("unexpected type %T" , s ))
177- }
178-
179165// SanitizeHTML sanitizes the input by default sanitization rules.
180166func SanitizeHTML (s string ) template.HTML {
181167 return markup .Sanitize (s )
182168}
183169
184- func htmlEscape (s any ) template.HTML {
185- switch v := s .(type ) {
186- case string :
187- return template .HTML (html .EscapeString (v ))
188- case template.HTML :
189- return v
190- }
191- panic (fmt .Sprintf ("unexpected type %T" , s ))
192- }
193-
194170func htmlFormat (s any , args ... any ) template.HTML {
195171 if len (args ) == 0 {
196172 // to prevent developers from calling "HTMLFormat $userInput" by mistake which will lead to XSS
0 commit comments