From 628fc34ae4c551d86cee84560f530f49492a3b09 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 5 Feb 2023 20:42:14 -0500 Subject: [PATCH] all inclusive danger zone --- docs/changelog.txt | 2 ++ docs/honk.5 | 3 ++- fun.go | 4 +++- web.go | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7d121d2..a9f7054 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next ++ All inclusive danger zone spoiler alerts. + + Emu peeker + CSP compliance diff --git a/docs/honk.5 b/docs/honk.5 index b15a96b..a215ce8 100644 --- a/docs/honk.5 +++ b/docs/honk.5 @@ -74,7 +74,8 @@ will become a horizontal rule. .Pp If the first line of a honk begins with .Dq DZ: -(danger zone) it will be used a summary and the post marked sensitive. +(danger zone) or any other combination of two letters and a colon, +it will be used a summary and the post marked sensitive. .Pp Mentioning a specfic user such as .Pq @user@example.social diff --git a/fun.go b/fun.go index 8226cd0..25e155a 100644 --- a/fun.go +++ b/fun.go @@ -290,12 +290,14 @@ func imaginate(honk *Honk) { htf.String(honk.Noise) } +var re_dangerous = regexp.MustCompile("^[a-zA-Z]{2}:") + func translate(honk *Honk) { if honk.Format == "html" { return } noise := honk.Noise - if strings.HasPrefix(noise, "DZ:") { + if re_dangerous.MatchString(noise) { idx := strings.Index(noise, "\n") if idx == -1 { honk.Precis = noise diff --git a/web.go b/web.go index c7e26b3..9fe1e7d 100644 --- a/web.go +++ b/web.go @@ -1662,7 +1662,7 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { honk.RID = rid if xonk.Precis != "" && honk.Precis == "" { honk.Precis = xonk.Precis - if !(strings.HasPrefix(honk.Precis, "DZ:") || strings.HasPrefix(honk.Precis, "re: re: re: ")) { + if !re_dangerous.MatchString(honk.Precis) { honk.Precis = "re: " + honk.Precis } }