fix: HIGH+MEDIUM bugs from full audit - listen error, JWT, upload, mailer, webhook

This commit is contained in:
2026-07-13 03:49:02 +08:00
parent 7c03fe7635
commit 532efb962f
8 changed files with 56 additions and 29 deletions

View File

@@ -33,13 +33,14 @@ function sanitize(value) {
}
function sanitizeBody(req, res, next) {
if (req.body) {
for (const key of Object.keys(req.body)) {
if (typeof req.body[key] === 'string') {
req.body[key] = sanitize(req.body[key]);
}
function walk(obj) {
if (!obj || typeof obj !== 'object') return;
for (const key of Object.keys(obj)) {
if (typeof obj[key] === 'string') obj[key] = sanitize(obj[key]);
else if (typeof obj[key] === 'object') walk(obj[key]);
}
}
walk(req.body);
next();
}