updated regex to disalow '_'

This commit is contained in:
bill bittner 2017-07-03 11:36:51 -07:00
parent 2206a60af5
commit dad912dd53
3 changed files with 4 additions and 4 deletions

View file

@ -82,10 +82,10 @@ function dragend_handler(ev) {
document.getElementById('publish-submit').addEventListener('click', function(event){
event.preventDefault();
var name = document.getElementById('publish-name').value;
var invalidCharacters = /[^\w,-]/.exec(name);
var invalidCharacters = /[^A-Za-z0-9,-]/.exec(name);
// validate 'name'
if (invalidCharacters) {
alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.');
alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, and "-" only.');
return;
} else if (name.length < 1) {
alert("You must enter a name for your claim");

View file

@ -58,7 +58,7 @@ function createProgressBar(element, size){
function stageAndPublish(file) {
var name = nameInput.value;
var invalidCharacters = /[^\w,-]/.exec(name);
var invalidCharacters = /[^A-Za-z0-9,-]/.exec(name);
// validate 'name'
if (invalidCharacters) {
alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.');

View file

@ -57,7 +57,7 @@ module.exports = app => {
}
// validate name
const name = body.name || file.name.substring(0, file.name.indexOf('.'));
const invalidCharacters = /[^\w,-]/.exec(name);
const invalidCharacters = /[^A-Za-z0-9,-]/.exec(name);
if (invalidCharacters) {
postToStats('publish', originalUrl, ip, 'Error: name');
res.status(400).send('Error: The name you provided is not allowed. Please use A-Z, a-z, 0-9, "_" and "-" only.');