all repos — honk @ fe929ad91cd75fb5ffdafc460b9fe53357de21b6

my fork of honk

move emuxifier into html filter to avoid link damage
Ted Unangst tedu@tedunangst.com
Mon, 03 Aug 2020 16:40:05 -0400
commit

fe929ad91cd75fb5ffdafc460b9fe53357de21b6

parent

9a63a4bc42b3661b2442a7afd482d10e12ea6c03

4 files changed, 28 insertions(+), 39 deletions(-)

jump to
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

=== next ++ Reduce interference between various text substitution rules. + + Fix crash in search with extra space. + Fix pubkey issue with domain only keys.
M fun.gofun.go

@@ -97,6 +97,29 @@ var htf htfilter.Filter

htf.Imager = replaceimgsand(zap, false) htf.SpanClasses = allowedclasses htf.BaseURL, _ = url.Parse(h.XID) + emuxifier := func(e string) string { + for _, d := range h.Donks { + if d.Name == e { + zap[d.XID] = true + if d.Local { + return fmt.Sprintf(`<img class="emu" title="%s" src="/d/%s">`, d.Name, d.XID) + } + } + } + if local && h.What != "bonked" { + var emu Emu + emucache.Get(e, &emu) + if emu.ID != "" { + return fmt.Sprintf(`<img class="emu" title="%s" src="%s">`, emu.Name, emu.ID) + } + } + return e + } + htf.FilterText = func(w io.Writer, data string) { + data = htfilter.EscapeText(data) + data = re_emus.ReplaceAllStringFunc(data, emuxifier) + io.WriteString(w, data) + } p, _ := htf.String(h.Precis) n, _ := htf.String(h.Noise) h.Precis = string(p)

@@ -115,41 +138,7 @@

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 { - for _, d := range h.Donks { - if d.Name == e { - zap[d.XID] = true - if d.Local { - return fmt.Sprintf(`<img class="emu" title="%s" src="/d/%s">`, d.Name, d.XID) - } - } - } - if local && h.What != "bonked" { - var emu Emu - emucache.Get(e, &emu) - if emu.ID != "" { - return fmt.Sprintf(`<img class="emu" title="%s" src="%s">`, emu.Name, emu.ID) - } - } - return e - } renderflags(h) - h.Precis = re_emus.ReplaceAllStringFunc(h.Precis, emuxifier) - h.Noise = re_emus.ReplaceAllStringFunc(h.Noise, emuxifier) - - 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] h.HTPrecis = template.HTML(h.Precis) h.HTML = template.HTML(h.Noise)
M go.modgo.mod

@@ -9,5 +9,5 @@ github.com/mattn/go-runewidth v0.0.6

golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/net v0.0.0-20190620200207-3b0461eec859 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 )
M go.sumgo.sum

@@ -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= 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/webs v0.6.41 h1:kteIzz03ij7EujsLLbRlquSgONRzoqIm1o1Bc5ie6HU= -humungus.tedunangst.com/r/webs v0.6.41/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= +humungus.tedunangst.com/r/webs v0.6.43 h1:V7tmvzXi/LETO2QfHyqvIivi1kbjRSHQoDFcR3hML+k= +humungus.tedunangst.com/r/webs v0.6.43/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=