safer to use templates sprintf to build html
This commit is contained in:
parent
9b8018ff26
commit
ad5a149f64
3
hoot.go
3
hoot.go
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue