From c5ab532e64231c97a453b7060eb4f8b2252d4ddf Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 17 Jun 2023 20:26:38 -0400 Subject: [PATCH] less aggressive rewrite filter rewriting --- hfcs.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hfcs.go b/hfcs.go index d51e541..1284805 100644 --- a/hfcs.go +++ b/hfcs.go @@ -20,6 +20,7 @@ import ( "regexp" "sort" "time" + "unicode" "humungus.tedunangst.com/r/webs/cache" ) @@ -109,8 +110,8 @@ func filtcachefiller(userid int64) (afiltermap, bool) { } } if t := filt.Text; t != "" && t != "." { - wordfront := t[0] != '#' - wordtail := true + wordfront := unicode.IsLetter(rune(t[0])) + wordtail := unicode.IsLetter(rune(t[len(t)-1])) t = "(?i:" + t + ")" if wordfront { t = "\\b" + t @@ -125,8 +126,8 @@ func filtcachefiller(userid int64) (afiltermap, bool) { } } if t := filt.Rewrite; t != "" { - wordfront := t[0] != '#' - wordtail := true + wordfront := unicode.IsLetter(rune(t[0])) + wordtail := unicode.IsLetter(rune(t[len(t)-1])) t = "(?i:" + t + ")" if wordfront { t = "\\b" + t