From 3b87f14199f76ecb11f7517ce1b4ca14ff9ca3ad Mon Sep 17 00:00:00 2001 From: b1ek Date: Sat, 18 Mar 2023 13:11:11 +1000 Subject: [PATCH] check for blank usrrname in guestbook (like " ") --- routes/guestbook.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/guestbook.js b/routes/guestbook.js index 58ddefa..caa08f5 100644 --- a/routes/guestbook.js +++ b/routes/guestbook.js @@ -46,7 +46,7 @@ async function submit(req, res, next) { if (message.length >= 512) { errors.push('Maximum length is 512 characters.'); } - if (name == '') { + if (name.match(/^\s*$/g)) { errors.push('Name must be specified.'); } if ( @@ -65,12 +65,12 @@ async function submit(req, res, next) { send_error(res, "

" + errors.join('
') + "

"); return; } + // done checking for errors req.session.gb_name = name; req.session.gb_email = email; req.session.gb_hidemail = req.body.hidemail; - // actual shit let records = await Sequelize.Guestbook.findAll({ where: { ip: req.ip