bump htfilter

This commit is contained in:
Ted Unangst 2019-10-22 02:02:36 -04:00
parent a34266b266
commit acd96f17ee
6 changed files with 19 additions and 20 deletions

26
fun.go
View File

@ -91,11 +91,11 @@ func reverbolate(userid int64, honks []*Honk) {
zap := make(map[string]bool) zap := make(map[string]bool)
{ {
filt := htfilter.New() var htf htfilter.Filter
filt.Imager = replaceimgsand(zap, false) htf.Imager = replaceimgsand(zap, false)
filt.SpanClasses = allowedclasses htf.SpanClasses = allowedclasses
p, _ := filt.String(h.Precis) p, _ := htf.String(h.Precis)
n, _ := filt.String(h.Noise) n, _ := htf.String(h.Noise)
h.Precis = string(p) h.Precis = string(p)
h.Noise = string(n) h.Noise = string(n)
} }
@ -180,9 +180,9 @@ func inlineimgsfor(honk *Honk) func(node *html.Node) string {
} }
func imaginate(honk *Honk) { func imaginate(honk *Honk) {
imgfilt := htfilter.New() var htf htfilter.Filter
imgfilt.Imager = inlineimgsfor(honk) htf.Imager = inlineimgsfor(honk)
imgfilt.String(honk.Noise) htf.String(honk.Noise)
} }
func translate(honk *Honk, redoimages bool) { func translate(honk *Honk, redoimages bool) {
@ -211,11 +211,11 @@ func translate(honk *Honk, redoimages bool) {
if redoimages { if redoimages {
zap := make(map[string]bool) zap := make(map[string]bool)
{ {
filt := htfilter.New() var htf htfilter.Filter
filt.Imager = replaceimgsand(zap, true) htf.Imager = replaceimgsand(zap, true)
filt.SpanClasses = allowedclasses htf.SpanClasses = allowedclasses
p, _ := filt.String(honk.Precis) p, _ := htf.String(honk.Precis)
n, _ := filt.String(honk.Noise) n, _ := htf.String(honk.Noise)
honk.Precis = string(p) honk.Precis = string(p)
honk.Noise = string(n) honk.Noise = string(n)
} }

2
go.mod
View File

@ -10,7 +10,7 @@ require (
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/net v0.0.0-20190620200207-3b0461eec859
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 humungus.tedunangst.com/r/go-sqlite3 v1.1.3
humungus.tedunangst.com/r/webs v0.6.17 humungus.tedunangst.com/r/webs v0.6.18
) )
go 1.11 go 1.11

2
go.sum
View File

@ -36,3 +36,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
humungus.tedunangst.com/r/webs v0.6.17 h1:d9kyIeS9lRinJrToI+7O6SUUiE/dSI7ke1T/Kmbm70A= humungus.tedunangst.com/r/webs v0.6.17 h1:d9kyIeS9lRinJrToI+7O6SUUiE/dSI7ke1T/Kmbm70A=
humungus.tedunangst.com/r/webs v0.6.17/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps= humungus.tedunangst.com/r/webs v0.6.17/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
humungus.tedunangst.com/r/webs v0.6.18 h1:5bho2umHAyT+DUTxbO9pCB3nETvuT7dgcc+3/voopTY=
humungus.tedunangst.com/r/webs v0.6.18/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=

View File

@ -78,7 +78,7 @@ func hootfixer(r io.Reader, url string) string {
wanted := wantmatch[1] wanted := wantmatch[1]
var buf strings.Builder var buf strings.Builder
filt := htfilter.New() var htf htfilter.Filter
fmt.Fprintf(&buf, "%s\n", url) fmt.Fprintf(&buf, "%s\n", url)
for _, div := range divs { for _, div := range divs {
twp := div.Parent.Parent.Parent twp := div.Parent.Parent.Parent
@ -97,7 +97,7 @@ func hootfixer(r io.Reader, url string) string {
if author != wanted { if author != wanted {
continue continue
} }
text := filt.TextOnly(div) text := htf.TextOnly(div)
text = strings.Replace(text, "\n", " ", -1) text = strings.Replace(text, "\n", " ", -1)
text = strings.Replace(text, "pic.twitter.com", "https://pic.twitter.com", -1) text = strings.Replace(text, "pic.twitter.com", "https://pic.twitter.com", -1)

View File

@ -76,4 +76,3 @@ func TestImagelink(t *testing.T) {
output := `an image <img alt="caption" src="https://example.com/wherever"> and linked <a class="mention u-url" href="example.com"><img src="there"></a>` output := `an image <img alt="caption" src="https://example.com/wherever"> and linked <a class="mention u-url" href="example.com"><img src="there"></a>`
doonezerotest(t, input, output) doonezerotest(t, input, output)
} }

4
web.go
View File

@ -34,7 +34,6 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"humungus.tedunangst.com/r/webs/cache" "humungus.tedunangst.com/r/webs/cache"
"humungus.tedunangst.com/r/webs/css" "humungus.tedunangst.com/r/webs/css"
"humungus.tedunangst.com/r/webs/htfilter"
"humungus.tedunangst.com/r/webs/httpsig" "humungus.tedunangst.com/r/webs/httpsig"
"humungus.tedunangst.com/r/webs/image" "humungus.tedunangst.com/r/webs/image"
"humungus.tedunangst.com/r/webs/junk" "humungus.tedunangst.com/r/webs/junk"
@ -572,11 +571,10 @@ func showuser(w http.ResponseWriter, r *http.Request) {
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
honks := gethonksbyuser(name, u != nil && u.Username == name, 0) honks := gethonksbyuser(name, u != nil && u.Username == name, 0)
templinfo := getInfo(r) templinfo := getInfo(r)
filt := htfilter.New()
templinfo["Name"] = user.Name templinfo["Name"] = user.Name
whatabout := user.About whatabout := user.About
whatabout = markitzero(user.About) whatabout = markitzero(user.About)
templinfo["WhatAbout"], _ = filt.String(whatabout) templinfo["WhatAbout"] = template.HTML(whatabout)
templinfo["ServerMessage"] = "" templinfo["ServerMessage"] = ""
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
honkpage(w, u, honks, templinfo) honkpage(w, u, honks, templinfo)