fix: round 10 critical fixes - WebSocket race, rate limiting, XSS protection, Caddyfile, and input validation

This commit is contained in:
2026-05-20 17:59:22 +08:00
parent a5b5713b29
commit 20cdcc748e
10 changed files with 336 additions and 25 deletions
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"html"
"io"
"log"
"net/http"
@@ -144,11 +145,11 @@ func (h *MemoryHandler) Add(c *gin.Context) {
userID = req.UserID
}
// 转发到 Memory-Service
// 转发到 Memory-Service(对用户输入进行 HTML 转义防 XSS)
memReq := map[string]interface{}{
"user_id": userID,
"content": req.Content,
"category": req.Category,
"content": html.EscapeString(req.Content),
"category": html.EscapeString(req.Category),
"priority": req.Priority,
}
reqBody, _ := json.Marshal(memReq)