use templates.sprintf helper
Ted Unangst tedu@tedunangst.com
Wed, 16 Oct 2019 18:45:19 -0400
1 files changed,
8 insertions(+),
11 deletions(-)
jump to
M
web.go
→
web.go
@@ -19,7 +19,6 @@ import (
"bytes" "database/sql" "fmt" - "html" "html/template" "io" "log"@@ -195,12 +194,12 @@ desc += fmt.Sprintf(`<br>Duration: %s`, t.Duration)
} } if p := honk.Place; p != nil { - desc += fmt.Sprintf(`<p>Location: <a href="%s">%s</a> %f %f`, - html.EscapeString(p.Url), html.EscapeString(p.Name), p.Latitude, p.Longitude) + desc += string(templates.Sprintf(`<p>Location: <a href="%s">%s</a> %f %f`, + p.Url, p.Name, p.Latitude, p.Longitude)) } for _, d := range honk.Donks { - desc += fmt.Sprintf(`<p><a href="%s">Attachment: %s</a>`, - d.URL, html.EscapeString(d.Name)) + desc += string(templates.Sprintf(`<p><a href="%s">Attachment: %s</a>`, + d.URL, d.Name)) } feed.Items = append(feed.Items, &rss.Item{@@ -593,12 +592,11 @@ honks = gethonksbyxonker(u.UserID, name)
} else { honks = gethonksbyhonker(u.UserID, name) } - name = html.EscapeString(name) - msg := fmt.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, name, name) + msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, name, name) templinfo := getInfo(r) templinfo["PageName"] = "honker" templinfo["PageArg"] = name - templinfo["ServerMessage"] = template.HTML(msg) + templinfo["ServerMessage"] = msg templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) honkpage(w, u, honks, templinfo) }@@ -1667,9 +1665,8 @@ if strings.IndexByte(xid, '@') != -1 {
xid = gofish(xid) } honks = gethonksbyxonker(userid, xid) - xid = html.EscapeString(xid) - msg := fmt.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, xid, xid) - templinfo["ServerMessage"] = template.HTML(msg) + msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, xid, xid) + templinfo["ServerMessage"] = msg default: http.NotFound(w, r) }