diff --git a/internal/core/middleware/XSS.go b/internal/core/middleware/XSS.go index cae1b41..5bc53a4 100644 --- a/internal/core/middleware/XSS.go +++ b/internal/core/middleware/XSS.go @@ -1,17 +1,22 @@ package middleware import ( - "html" "net/http" + "regexp" "strings" ) type XSSProtection struct{} +// Creates a new middleware for XSS protection func NewXSSProtection() *XSSProtection { return &XSSProtection{} } +// Regular expression to detect potentially harmful XSS patterns, including encoded variants +var unsafePattern = regexp.MustCompile(`(?i)|javascript:|data:text/html|onerror=|onload=|onclick=|