|
|
|
@ -646,7 +646,7 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1
|
|
|
|
|
if (req.files['answer'][0].size > syzoj.config.limit.submit_code) throw new ErrorMessage('代码文件太大。'); |
|
|
|
|
code = (await fs.readFile(req.files['answer'][0].path)).toString(); |
|
|
|
|
} else { |
|
|
|
|
if (req.body.code.length > syzoj.config.limit.submit_code) throw new ErrorMessage('代码太长。'); |
|
|
|
|
if (Buffer.from(req.body.code).length > syzoj.config.limit.submit_code) throw new ErrorMessage('代码太长。'); |
|
|
|
|
code = req.body.code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -655,7 +655,7 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1
|
|
|
|
|
status: 'Unknown', |
|
|
|
|
task_id: randomstring.generate(10), |
|
|
|
|
code: code, |
|
|
|
|
code_length: code.length, |
|
|
|
|
code_length: Buffer.from(code).length, |
|
|
|
|
language: req.body.language, |
|
|
|
|
user_id: curUser.id, |
|
|
|
|
problem_id: req.params.id, |
|
|
|
@ -930,7 +930,7 @@ app.post('/problem/:id/custom-test', app.multer.fields([{ name: 'code_upload', m
|
|
|
|
|
if (req.files['code_upload'][0].size > syzoj.config.limit.submit_code) throw new ErrorMessage('代码过长。'); |
|
|
|
|
code = (await require('fs-extra').readFileAsync(req.files['code_upload'][0].path)).toString(); |
|
|
|
|
} else { |
|
|
|
|
if (req.body.code.length > syzoj.config.limit.submit_code) throw new ErrorMessage('代码过长。'); |
|
|
|
|
if (Buffer.from(req.body.code).length > syzoj.config.limit.submit_code) throw new ErrorMessage('代码过长。'); |
|
|
|
|
code = req.body.code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|