diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 4b671f920..a6a984fd8 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -29,7 +29,6 @@ "fs-extra": "^11.1.0", "graphql": "^16.6.0", "graphql-scalars": "1.20.1", - "isbinaryfile": "^5.0.0", "js-yaml": "^4.1.0", "koa": "^2.14.1", "koa-body": "^6.0.1", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index b7fcbc79d..c0f7d3a40 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -1,6 +1,5 @@ import AdmZip from 'adm-zip'; import { readFile, statSync } from 'fs-extra'; -import { isBinaryFile } from 'isbinaryfile'; import { escapeRegExp, flattenDeep, intersection, pick, uniqBy, } from 'lodash'; @@ -524,8 +523,9 @@ export class ProblemSubmitHandler extends ProblemDetailHandler { if (!file || file.size === 0) throw new ValidationError('code'); const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : 65535; if (file.size > sizeLimit) throw new ValidationError('file'); - if (config.type !== 'submit_answer' || (file.size < 65535 && !await isBinaryFile(file.filepath, file.size))) { + if (file.size < 65535 && !file.filepath.endsWith('.zip')) { // TODO auto detect & convert encoding + // TODO submission file shape code = await readFile(file.filepath, 'utf-8'); } else { const id = nanoid();