Add profanity filter for subdomain validation
- Integrate github.com/TwiN/go-away for content filtering - Check subdomains for inappropriate content during validation - Update frontend to display 'inappropriate content' message - Blocks profane subdomains from being claimed Uses go-away's built-in profanity dictionary to detect: - Leet speak substitutions (e.g., @73447h013) - Obfuscated profanity - Common inappropriate terms
This commit is contained in:
@@ -12,9 +12,12 @@ import (
|
||||
"git.dws.rip/DWS/dyn/internal/database"
|
||||
"git.dws.rip/DWS/dyn/internal/dns"
|
||||
"git.dws.rip/DWS/dyn/internal/models"
|
||||
"github.com/TwiN/go-away"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var profanityDetector = goaway.NewProfanityDetector()
|
||||
|
||||
type WebHandler struct {
|
||||
db *database.DB
|
||||
config *config.Config
|
||||
@@ -49,6 +52,11 @@ func (h *WebHandler) ClaimSpace(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if profanityDetector.IsProfane(subdomain) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Subdomain contains inappropriate content"})
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -86,6 +94,15 @@ func (h *WebHandler) CheckSubdomain(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if profanityDetector.IsProfane(subdomain) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"available": false,
|
||||
"subdomain": subdomain,
|
||||
"reason": "inappropriate",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user