move emuxifier into html filter to avoid link damage

This commit is contained in:
Ted Unangst 2020-08-03 16:40:05 -04:00
parent 4e052bcfde
commit 4b89e0a43a
4 changed files with 28 additions and 39 deletions

View File

@ -2,6 +2,8 @@ changelog
=== next === next
+ Reduce interference between various text substitution rules.
+ Fix crash in search with extra space. + Fix crash in search with extra space.
+ Fix pubkey issue with domain only keys. + Fix pubkey issue with domain only keys.

43
fun.go
View File

@ -97,29 +97,6 @@ func reverbolate(userid int64, honks []*Honk) {
htf.Imager = replaceimgsand(zap, false) htf.Imager = replaceimgsand(zap, false)
htf.SpanClasses = allowedclasses htf.SpanClasses = allowedclasses
htf.BaseURL, _ = url.Parse(h.XID) htf.BaseURL, _ = url.Parse(h.XID)
p, _ := htf.String(h.Precis)
n, _ := htf.String(h.Noise)
h.Precis = string(p)
h.Noise = string(n)
}
j := 0
for i := 0; i < len(h.Donks); i++ {
if !zap[h.Donks[i].XID] {
h.Donks[j] = h.Donks[i]
j++
}
}
h.Donks = h.Donks[:j]
}
unsee(honks, userid)
for _, h := range honks {
local := false
if h.Whofore == 2 || h.Whofore == 3 {
local = true
}
zap := make(map[string]bool)
emuxifier := func(e string) string { emuxifier := func(e string) string {
for _, d := range h.Donks { for _, d := range h.Donks {
if d.Name == e { if d.Name == e {
@ -138,10 +115,16 @@ func reverbolate(userid int64, honks []*Honk) {
} }
return e return e
} }
renderflags(h) htf.FilterText = func(w io.Writer, data string) {
h.Precis = re_emus.ReplaceAllStringFunc(h.Precis, emuxifier) data = htfilter.EscapeText(data)
h.Noise = re_emus.ReplaceAllStringFunc(h.Noise, emuxifier) data = re_emus.ReplaceAllStringFunc(data, emuxifier)
io.WriteString(w, data)
}
p, _ := htf.String(h.Precis)
n, _ := htf.String(h.Noise)
h.Precis = string(p)
h.Noise = string(n)
}
j := 0 j := 0
for i := 0; i < len(h.Donks); i++ { for i := 0; i < len(h.Donks); i++ {
if !zap[h.Donks[i].XID] { if !zap[h.Donks[i].XID] {
@ -150,6 +133,12 @@ func reverbolate(userid int64, honks []*Honk) {
} }
} }
h.Donks = h.Donks[:j] h.Donks = h.Donks[:j]
}
unsee(honks, userid)
for _, h := range honks {
renderflags(h)
h.HTPrecis = template.HTML(h.Precis) h.HTPrecis = template.HTML(h.Precis)
h.HTML = template.HTML(h.Noise) h.HTML = template.HTML(h.Noise)

2
go.mod
View File

@ -9,5 +9,5 @@ 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.42 humungus.tedunangst.com/r/webs v0.6.43
) )

6
go.sum
View File

@ -22,7 +22,5 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI= humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=
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.41 h1:kteIzz03ij7EujsLLbRlquSgONRzoqIm1o1Bc5ie6HU= humungus.tedunangst.com/r/webs v0.6.43 h1:V7tmvzXi/LETO2QfHyqvIivi1kbjRSHQoDFcR3hML+k=
humungus.tedunangst.com/r/webs v0.6.41/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps= humungus.tedunangst.com/r/webs v0.6.43/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
humungus.tedunangst.com/r/webs v0.6.42 h1:y1j7Z04Bs8/UmzYwsQb2OfOs1F1veJ6u9bwjc70PhLo=
humungus.tedunangst.com/r/webs v0.6.42/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=