mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
dev day #89
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user