From de18f826f0f3eb477ebe448f01dae7f119a84980 Mon Sep 17 00:00:00 2001
From: Antonin <antonin.murtin@gmail.com>
Date: Mon, 12 Oct 2015 21:26:13 +0200
Subject: [PATCH] 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
---
 adminstuds.php                                  | 1 -
 app/classes/Framadate/Services/InputService.php | 2 +-
 app/inc/constants.php                           | 1 -
 js/app/studs.js                                 | 5 ++---
 studs.php                                       | 1 -
 tpl/studs.tpl                                   | 4 ----
 6 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/adminstuds.php b/adminstuds.php
index 388d9c2d..3f30a418 100644
--- a/adminstuds.php
+++ b/adminstuds.php
@@ -431,6 +431,5 @@ $smarty->assign('editingVoteId', $editingVoteId);
 $smarty->assign('message', $message);
 $smarty->assign('admin', true);
 $smarty->assign('hidden', false);
-$smarty->assign('parameter_name_regex', NAME_REGEX);
 
 $smarty->display('studs.tpl');
diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php
index 31b3103d..29e8a423 100644
--- a/app/classes/Framadate/Services/InputService.php
+++ b/app/classes/Framadate/Services/InputService.php
@@ -55,7 +55,7 @@ class InputService {
     }
 
     public function filterName($name) {
-        $filtered = filter_var($name, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => NAME_REGEX]]);
+        $filtered = trim($name);
         return $this->returnIfNotBlank($filtered);
     }
 
diff --git a/app/inc/constants.php b/app/inc/constants.php
index d1db10a0..166b21bf 100644
--- a/app/inc/constants.php
+++ b/app/inc/constants.php
@@ -23,7 +23,6 @@ const VERSION = '0.9';
 // Regex
 const POLL_REGEX = '/^[a-z0-9]+$/i';
 const CHOICE_REGEX = '/^[012]$/';
-const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i';
 const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i';
 const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i';
 const EDITABLE_CHOICE_REGEX = '/^[0-2]$/';
diff --git a/js/app/studs.js b/js/app/studs.js
index 52fd1021..2ef5aeec 100644
--- a/js/app/studs.js
+++ b/js/app/studs.js
@@ -20,10 +20,9 @@ $(document).ready(function () {
 
     $("#poll_form").submit(function (event) {
         var name = $("#name").val();
-        var regexContent = $("#parameter_name_regex").text().split("/");
-        var regex = new RegExp(regexContent[1], regexContent[2]);
+        name = name.trim();
 
-        if (name.length == 0 || !regex.test(name)) {
+        if (name.length == 0) {
             event.preventDefault();
             var newMessage = $("#nameErrorMessage").clone();
             $("#message-container").empty();
diff --git a/studs.php b/studs.php
index abde6ed8..52b90962 100644
--- a/studs.php
+++ b/studs.php
@@ -216,6 +216,5 @@ $smarty->assign('editingVoteId', $editingVoteId);
 $smarty->assign('message', $message);
 $smarty->assign('admin', false);
 $smarty->assign('hidden', $poll->hidden);
-$smarty->assign('parameter_name_regex', NAME_REGEX);
 
 $smarty->display('studs.tpl');
diff --git a/tpl/studs.tpl b/tpl/studs.tpl
index aaddc992..f84fe6a7 100644
--- a/tpl/studs.tpl
+++ b/tpl/studs.tpl
@@ -48,10 +48,6 @@
     </div>
 </div>
 
-<div class="hidden">
-    <p id="parameter_name_regex">{$parameter_name_regex}</p>
-</div>
-
 
 {* Vote table *}
 
-- 
GitLab