core: import: handle error message for invalid zip

This commit is contained in:
undefined committed 2022-09-27 02:43:19 +08:00
1 parent cb424c9cac
commit 895d50530a
4 files changed
+24 -4

No files matched your search

+6 -1
View File
@@ -727,7 +727,12 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
if (!this.user.own(this.pdoc, PERM.PERM_EDIT_PROBLEM_SELF)) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
const files = [];
if (filename.endsWith('.zip') && type === 'testdata') {
const zip = new AdmZip(this.request.files.file.filepath);
let zip: AdmZip;
try {
zip = new AdmZip(this.request.files.file.filepath);
} catch (e) {
throw new ValidationError('zip', null, e.message);
}
const entries = zip.getEntries();
for (const entry of entries) {
if (!entry.name) continue;