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