From b281ab866f707298f9ee701fc78dc72847546cd4 Mon Sep 17 00:00:00 2001 From: Su Yijun Date: Sun, 25 Oct 2026 15:26:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=200.6.16=20=E7=9A=84=E4=B8=AD=E8=BD=AC?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=9C=A8=E7=94=9F=E4=BA=A7=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=20classifier=EF=BC=88=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95=E7=94=9F=E6=95=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/share.py | 3 ++- backend/app/share.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/app/routers/share.py b/backend/app/routers/share.py index e4bd654..92dc0f0 100644 --- a/backend/app/routers/share.py +++ b/backend/app/routers/share.py @@ -30,8 +30,9 @@ def collect(req: Request, body: dict): entries = (body or {}).get("entries") if not reporter or not isinstance(entries, list): raise HTTPException(400, "格式不对:需要 instance 和 entries") + from app.engine import engine with database.session() as db: - accepted = share.collect(db, reporter, entries) + accepted = share.collect(db, reporter, entries, domains, engine.classifier) db.commit() return {"ok": True, "accepted": accepted} diff --git a/backend/app/share.py b/backend/app/share.py index 3b1b329..104f775 100644 --- a/backend/app/share.py +++ b/backend/app/share.py @@ -106,7 +106,10 @@ def export_domains(engine, db) -> list[dict]: def _valid_app(classifier, app: str) -> bool: - """应用白名单(debug20):只收所有实例都认识的应用;自定义应用和编造的 ID 拒收""" + """应用白名单(debug20):只收所有实例都认识的应用;自定义应用和编造的 ID 拒收。 + classifier 传 None 时只按 ID 形状校验(测试直调用)""" + if classifier is None: + return bool(app) and len(app) <= 48 and app != "other" and not app.startswith("custom_") info = classifier.apps.get(app) return info is not None and not info.custom