The name can be any value.

There is no reason to limit the caracters that can be used in the name.
Thus, removing the regex.

Fix #97
This commit is contained in:
Antonin 2015-10-12 21:26:13 +02:00
parent 8d543f7c23
commit de18f826f0
6 changed files with 3 additions and 11 deletions

View File

@ -431,6 +431,5 @@ $smarty->assign('editingVoteId', $editingVoteId);
$smarty->assign('message', $message); $smarty->assign('message', $message);
$smarty->assign('admin', true); $smarty->assign('admin', true);
$smarty->assign('hidden', false); $smarty->assign('hidden', false);
$smarty->assign('parameter_name_regex', NAME_REGEX);
$smarty->display('studs.tpl'); $smarty->display('studs.tpl');

View File

@ -55,7 +55,7 @@ class InputService {
} }
public function filterName($name) { public function filterName($name) {
$filtered = filter_var($name, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => NAME_REGEX]]); $filtered = trim($name);
return $this->returnIfNotBlank($filtered); return $this->returnIfNotBlank($filtered);
} }

View File

@ -23,7 +23,6 @@ const VERSION = '0.9';
// Regex // Regex
const POLL_REGEX = '/^[a-z0-9]+$/i'; const POLL_REGEX = '/^[a-z0-9]+$/i';
const CHOICE_REGEX = '/^[012]$/'; const CHOICE_REGEX = '/^[012]$/';
const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i';
const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i'; const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i';
const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i'; const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i';
const EDITABLE_CHOICE_REGEX = '/^[0-2]$/'; const EDITABLE_CHOICE_REGEX = '/^[0-2]$/';

View File

@ -20,10 +20,9 @@ $(document).ready(function () {
$("#poll_form").submit(function (event) { $("#poll_form").submit(function (event) {
var name = $("#name").val(); var name = $("#name").val();
var regexContent = $("#parameter_name_regex").text().split("/"); name = name.trim();
var regex = new RegExp(regexContent[1], regexContent[2]);
if (name.length == 0 || !regex.test(name)) { if (name.length == 0) {
event.preventDefault(); event.preventDefault();
var newMessage = $("#nameErrorMessage").clone(); var newMessage = $("#nameErrorMessage").clone();
$("#message-container").empty(); $("#message-container").empty();

View File

@ -216,6 +216,5 @@ $smarty->assign('editingVoteId', $editingVoteId);
$smarty->assign('message', $message); $smarty->assign('message', $message);
$smarty->assign('admin', false); $smarty->assign('admin', false);
$smarty->assign('hidden', $poll->hidden); $smarty->assign('hidden', $poll->hidden);
$smarty->assign('parameter_name_regex', NAME_REGEX);
$smarty->display('studs.tpl'); $smarty->display('studs.tpl');

View File

@ -48,10 +48,6 @@
</div> </div>
</div> </div>
<div class="hidden">
<p id="parameter_name_regex">{$parameter_name_regex}</p>
</div>
{* Vote table *} {* Vote table *}