fix regex accepting possible incorrect names, also make case insensitive

jschan
Thomas Lynch 3 years ago
parent 3cf216450e
commit 9edbac671a
  1. 2
      controllers/forms/addcustompage.js
  2. 2
      controllers/forms/editcustompage.js
  3. 2
      views/pages/editcustompage.pug
  4. 2
      views/pages/managecustompages.pug

@ -25,7 +25,7 @@ module.exports = {
{ result: existsBody(req.body.page), expected: true, error: 'Missing .html name' },
{ result: () => {
if (req.body.page) {
return /[a-z0-9_-]+/.test(req.body.page);
return /^[a-z0-9_-]+$/i.test(req.body.page);
}
return false;
} , expected: true, error: '.html name must contain a-z 0-9 _ - only' },

@ -27,7 +27,7 @@ module.exports = {
{ result: existsBody(req.body.page), expected: true, error: 'Missing .html name' },
{ result: () => {
if (req.body.page) {
return /[a-z0-9_-]+/.test(req.body.page);
return /^[a-z0-9_-]+$/i.test(req.body.page);
}
return false;
} , expected: true, error: '.html name must contain a-z 0-9 _ - only' },

@ -12,7 +12,7 @@ block content
input(type='hidden' name='page_id' value=page._id)
.row
.label .html name
input(type='text' name='page' pattern='[a-z0-9-_]+' title='a-z0-9-_ only' value=page.page required)
input(type='text' name='page' pattern='[a-zA-Z0-9-_]+' title='a-zA-Z0-9-_ only' value=page.page required)
.table-container.flex-center.mv-5
table
tr

@ -17,7 +17,7 @@ block content
input(type='hidden' name='_csrf' value=csrf)
.row
.label .html name
input(type='text' name='page' pattern='[a-z0-9-_]+' title='a-z0-9-_ only' required)
input(type='text' name='page' pattern='[a-zA-Z0-9-_]+' title='a-zA-Z0-9-_ only' required)
.row
.label Title
input(type='text' name='title' required)

Loading…
Cancel
Save