mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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}`;
|
||||
const n = await ProblemModel.get(domainId, pdoc.display_id);
|
||||
if (n) pdoc.display_id = null;
|
||||
const isValidPid = async (id: string) => {
|
||||
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(
|
||||
domainId, pdoc.display_id, pdoc.title, buildContent(content, 'html'),
|
||||
this.user._id, pdoc.tags || [],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/import-qduoj",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"description": "Import QDUOJ problem export",
|
||||
"main": "index.ts",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
Reference in new issue
Block a user