mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-10-28 15:41:16 +00:00
dev day #89
This commit is contained in:
1 parent
d5b4faea61
commit
8762bde4bf
139 files changed
+7240
-2870
No files matched your search
@@ -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