safer to use templates sprintf to build html

This commit is contained in:
Ted Unangst 2023-02-11 19:56:27 -05:00
parent 9b8018ff26
commit ad5a149f64
1 changed files with 2 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import (
"github.com/andybalholm/cascadia" "github.com/andybalholm/cascadia"
"golang.org/x/net/html" "golang.org/x/net/html"
"humungus.tedunangst.com/r/webs/htfilter" "humungus.tedunangst.com/r/webs/htfilter"
"humungus.tedunangst.com/r/webs/templates"
) )
var tweetsel = cascadia.MustCompile("div[data-testid=tweetText]") var tweetsel = cascadia.MustCompile("div[data-testid=tweetText]")
@ -57,7 +58,7 @@ func hootextractor(r io.Reader, url string, seen map[string]bool) string {
if htfilter.HasClass(node, "Emoji") && alt != "" { if htfilter.HasClass(node, "Emoji") && alt != "" {
return alt return alt
} }
return fmt.Sprintf(" <img src='%s' alt='%s'>", htfilter.GetAttr(node, "src"), alt) return string(templates.Sprintf(" <img src='%s' alt='%s'>", htfilter.GetAttr(node, "src"), alt))
} }
var buf strings.Builder var buf strings.Builder