🐛 修复主题静态资源错误回退

避免缺失或越界的主题资源被全局 SPA 404 回退误返回首页 200,保持静态资源请求的明确 404 语义。

- 为主题资源回退增加显式 404 响应
- 增加缺失资源与路径穿越回归测试
This commit is contained in:
orion committed 2026-08-07 09:23:56 +08:00
1 parent 0be5a31a59
commit c25c495657
2 files changed
+22 -1

No files matched your search

+2
View File
@@ -891,6 +891,8 @@ async def theme_asset(asset_path: str):
@app.exception_handler(404)
@app.get("/")
async def index(request=None, exc=None):
if request is not None and request.url.path.startswith(("/assets/", "/theme-assets/")):
return PlainTextResponse("Not found", status_code=404)
theme_dir = resolve_theme_root()
index_file = resolve_theme_file("index.html")
asset_version = str(int(index_file.stat().st_mtime))