judge: submit_answer: support wildcard filename

This commit is contained in:
undefined committed 2022-04-14 17:45:27 +08:00
1 parent 76be3ebbb1
commit 39c5e7661b
2 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.17.1",
"version": "2.17.2",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
@@ -35,7 +35,9 @@ function judgeCase(c: Case, sid: string) {
return;
}
const chars = /[a-zA-Z0-9_.-]/;
const name = await readFile(c.input, 'utf-8').then((res) => res.trim().split('').filter((i) => chars.test(i)).join(''));
const name = (ctx.config.filename && /^[a-zA-Z0-9-_#.]+$/.test(ctx.config.filename))
? ctx.config.filename.replace('#', c.id.toString())
: await readFile(c.input, 'utf-8').then((res) => res.trim().split('').filter((i) => chars.test(i)).join(''));
let file = ctx.code;
let status = STATUS.STATUS_ACCEPTED;
let message: any = '';