core: import: check pid validity

This commit is contained in:
undefined committed 2023-05-18 15:00:44 +08:00
1 parent de492550a6
commit 27833d6c53
1 file changed
+2 -2
+2 -2
View File
@@ -442,8 +442,8 @@ export class ProblemModel {
if (!pdoc) continue;
let pid = pdoc.pid;
if (pid) {
const current = await ProblemModel.get(domainId, pid);
if (current) pid = undefined;
if (!(/^[A-Za-z]+[0-9]*$/.test(pid))) pid = undefined;
else if (await ProblemModel.get(domainId, pid)) pid = undefined;
}
const overrideContent = findOverrideContent(path.join(tmpdir, i));
const docId = await ProblemModel.add(