mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
import-qduoj: add pid validity check
This commit is contained in:
2 files changed
+7
-3
No files matched your search
@@ -77,8 +77,12 @@ class ImportQduojHandler extends Handler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (+pdoc.display_id) pdoc.display_id = `P${pdoc.display_id}`;
|
if (+pdoc.display_id) pdoc.display_id = `P${pdoc.display_id}`;
|
||||||
const n = await ProblemModel.get(domainId, pdoc.display_id);
|
const isValidPid = async (id: string) => {
|
||||||
if (n) pdoc.display_id = null;
|
if (!(/^[A-Za-z]+[0-9A-Za-z]*$/.test(id))) return false;
|
||||||
|
if (await ProblemModel.get(domainId, id)) return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
if (!await isValidPid(pdoc.display_id)) pdoc.display_id = null;
|
||||||
const pid = await ProblemModel.add(
|
const pid = await ProblemModel.add(
|
||||||
domainId, pdoc.display_id, pdoc.title, buildContent(content, 'html'),
|
domainId, pdoc.display_id, pdoc.title, buildContent(content, 'html'),
|
||||||
this.user._id, pdoc.tags || [],
|
this.user._id, pdoc.tags || [],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/import-qduoj",
|
"name": "@hydrooj/import-qduoj",
|
||||||
"version": "1.5.3",
|
"version": "1.5.4",
|
||||||
"description": "Import QDUOJ problem export",
|
"description": "Import QDUOJ problem export",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
Reference in new issue
Block a user