fix: 品牌下发审查修复(esc统一/语料中性化/穿越加固/反向断言动态化)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -49,10 +49,9 @@ async def ws_chat(websocket: WebSocket):
|
||||
init_msg = json.loads(init_data)
|
||||
|
||||
# Task 10: 客户端自报 site(空域名站点如 es 靠嵌入代码 data-site
|
||||
# 接入)记入 client_info 作会话站点标——只加记录,不参与业务逻辑
|
||||
# 接入)作会话站点标——只加记录,不参与业务逻辑;写入点在下方
|
||||
# 新建会话处(优先级对齐 REST,见那里注释)
|
||||
site_slug = str(init_msg.get("site") or "").strip()
|
||||
if site_slug:
|
||||
client_info["site"] = site_slug
|
||||
|
||||
if "session_id" in init_msg:
|
||||
conv = await manager.get_by_session(init_msg["session_id"])
|
||||
@@ -84,6 +83,11 @@ async def ws_chat(websocket: WebSocket):
|
||||
# 无 XFF 时保留客户端自报,user_agent 等其他字段不受影响
|
||||
if forwarded:
|
||||
merged_info["ip"] = forwarded
|
||||
# Task 10 复审: 专用 site 字段同样赢过 init_msg.client_info
|
||||
# 自报的 site(与 REST ?site= 覆盖 req.client_info 的优先级
|
||||
# 对齐——专用通道是嵌入代码显式声明,可信度高于任意自报 dict)
|
||||
if site_slug:
|
||||
merged_info["site"] = site_slug
|
||||
conv = await manager.create_conversation(
|
||||
source=source,
|
||||
client_info=merged_info,
|
||||
|
||||
@@ -76,6 +76,11 @@ async def avatar(request: Request):
|
||||
# "/static/kefu-small.png" 这类路径,取基名后拼租户 assets 目录,无路径
|
||||
# 逃逸面(单成分文件名不可能越出 assets/)
|
||||
name = pathlib.PurePosixPath(str(site.brand.get("avatar") or "")).name
|
||||
# 复审加固: PurePosixPath 不认反斜杠(整串留在 .name 里),Windows 文件
|
||||
# 系统却把反斜杠当分隔符——seed_dir/assets/.. 会真穿出资产目录 serve
|
||||
# 任意文件。显式拒绝分隔符与目录点,命中即回退静态兜底。
|
||||
if name in {".", ".."} or "/" in name or "\\" in name:
|
||||
name = ""
|
||||
candidate = runtime.seed_dir / "assets" / name if name else None
|
||||
if candidate is not None and candidate.is_file():
|
||||
return FileResponse(
|
||||
|
||||
Reference in New Issue
Block a user