enforce alphanumeric for board URIs

merge-requests/208/head
fatchan 5 years ago
parent f789d8eca1
commit 6684639f48
  1. 9
      controllers/forms.js
  2. 2
      views/pages/create.pug

@ -159,8 +159,13 @@ router.post('/create', csrf, verifyCaptcha, (req, res, next) => {
}
//check exist
if (req.body.uri && req.body.uri.length > 50) {
errors.push('URI must be 50 characters or less');
if (req.body.uri) {
if (req.body.uri.length > 50) {
errors.push('URI must be 50 characters or less');
}
if (!req.body.uri.match(/^[a-zA-Z0-9]+$/)) {
errors.push('URI must contain a-z 0-9 only');
}
}
if (req.body.name && req.body.name.length > 50) {
errors.push('Name must be 50 characters or less');

@ -10,7 +10,7 @@ block content
input(type='hidden' name='_csrf' value=csrf)
section.row
.label URI e.g. /uri/
input(type='text', name='uri', maxlength='50' required)
input(type='text', name='uri', maxlength='50' pattern='[a-zA-Z0-9]+' required title='alphanumeric only')
section.row
.label Name
input(type='text', name='name', maxlength='50' required)

Loading…
Cancel
Save