fix: 端口更换 & 代码审核修复

端口:
- 服务端口 8000 → 7329
- 前端开发端口 5173 → 7330

安全:
- CORS 收紧为白名单,关闭 credentials
- SPA 路由白名单完善
- 前端 XSS 转义

可靠性:
- 时区统一为 datetime.now(timezone.utc)
- 文章入库改为内存去重 + 增量计数
- OPML 导入改为 body 参数接收
- OPML 导出 URL XML 转义
- 首次抓取改为 BackgroundTasks 异步
- articles.py HTTPException 移到顶部 import
- FTS5 异常显式日志
- FTS5 查询加引号包裹防布尔注入
- 中文摘要支持中文标点
- 去掉未使用的 hashlib import

部署:
- Dockerfile 锁 python:3.12.7-slim
- requirements 锁定具体版本
- healthcheck 不用 curl(镜像里没有)
- docker-compose 使用 .env 文件
- 新增 .env 配置文件
This commit is contained in:
congsh
2026-06-11 14:31:29 +08:00
parent 54e7db0ef0
commit c59dd304f7
17 changed files with 701 additions and 106 deletions
+6 -1
View File
@@ -10,8 +10,13 @@ def search_articles(query: str, limit: int = 50, offset: int = 0):
if not query or not query.strip():
return [], 0
# 转义 FTS5 特殊字符
# 转义 FTS5 特殊字符(双引号、* 等)
# 简单策略:将用户查询视为一个整体短语,加引号包裹
query = query.replace('"', '""').strip()
if not query:
return [], 0
# 用双引号包裹,避免 FTS5 布尔操作符被误解析
query = f'"{query}"'
conn = engine.raw_connection()
cursor = conn.cursor()