Explorar el Código

【优化】非法字符检查

PJ-568 hace 2 años
padre
commit
fa8a6662bf
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  1. 2 2
      server/server.py

+ 2 - 2
server/server.py

@@ -58,7 +58,7 @@ class ChatServer(http.server.BaseHTTPRequestHandler):
                 lang = query_params.get('lang', [self.get_preferred_language()])[0]
                 
                 # 检查非法字符
-                illegal_chars = ['<', '>', '&', '"', "'"]
+                illegal_chars = ['<', '>', '&', '"', "'", "\\"]
                 if any(char in roomid for char in illegal_chars):
                     self.send_msg_error(400, "Bad Request: RoomID contains illegal characters.<br>房间号包含非法字符。")
                     return
@@ -105,7 +105,7 @@ class ChatServer(http.server.BaseHTTPRequestHandler):
                 message = post_data.get('messageInput', [''])[0]
 
                 # 检查非法字符
-                illegal_chars = ['<', '>', '&', '"', "'"]
+                illegal_chars = ['<', '>', '&', '"', "'", "\\"]
                 if any(char in message for char in illegal_chars):
                     self.send_msg_error(400, f"Bad Request: Message contains illegal characters.<br>消息包含非法字符。", f"<a href='./chat?nickname={nickname}&roomid={roomid}'>Back | 返回</a>")
                     return