all inclusive danger zone

master
Ted Unangst 1 year ago
parent 50524cade2
commit 628fc34ae4

@ -2,6 +2,8 @@ changelog
=== next
+ All inclusive danger zone spoiler alerts.
+ Emu peeker
+ CSP compliance

@ -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

@ -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

@ -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
}
}

Loading…
Cancel
Save