This commit is contained in:
Tomas Dvorak
2025-11-11 10:29:30 +01:00
parent d5b4faea61
commit 8762bde4bf
139 changed files with 7240 additions and 2870 deletions
+21 -3
View File
@@ -98,9 +98,27 @@ func isExcessiveCaps(text string) bool {
// Helper: detect excessive character repetition (e.g., "aaaaaa", "!!!!!!")
func hasExcessiveRepetition(text string) bool {
// Check for 5+ consecutive identical characters
re := regexp.MustCompile(`(.)\1{4,}`)
return re.MatchString(text)
// Check for 5+ consecutive identical characters without using backreferences (unsupported in Go regex)
run := 1
var prev rune
first := true
for _, r := range text {
if first {
prev = r
first = false
continue
}
if r == prev {
run++
if run >= 5 {
return true
}
} else {
prev = r
run = 1
}
}
return false
}
// SanitizeCommentContent removes dangerous HTML but preserves basic formatting