From 02b2263fd9ed2f074fec7f504de1e5e80739dc04 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 11 Nov 2022 13:38:34 +0800 Subject: [PATCH] core: validator.isContent: trim before length check --- packages/hydrooj/src/lib/validator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hydrooj/src/lib/validator.ts b/packages/hydrooj/src/lib/validator.ts index 277a0741c..9a62fa9b3 100644 --- a/packages/hydrooj/src/lib/validator.ts +++ b/packages/hydrooj/src/lib/validator.ts @@ -18,7 +18,7 @@ export const isPassword = (s) => s.length >= 5; export const checkPassword = (s) => { if (!(s && s.length >= 5)) throw new ValidationError('password'); else return s; }; export const isEmail = (s) => RE_MAIL.test(s); export const checkEmail = (s) => { if (!RE_MAIL.test(s)) throw new ValidationError('mail'); else return s; }; -export const isContent = (s: any) => s && s.length < 65536; +export const isContent = (s: any) => s && s.toString().trim().length < 65536; export const checkContent = (s) => { if (!(s && s.length < 65536)) throw new ValidationError('content'); else return s; }; export const isPid = (s) => RE_PID.test(s.toString()); export const checkPid = (s) => { if (!RE_PID.test(s)) throw new ValidationError('pid'); else return s; };