From 199e41ec939ff9ec2c66a22a910a91b888b68a46 Mon Sep 17 00:00:00 2001 From: Olivier Perez Date: Tue, 14 Apr 2015 13:34:42 +0200 Subject: [PATCH] Fix: description was required --- app/classes/Framadate/Services/InputService.php | 3 ++- app/inc/constants.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/classes/Framadate/Services/InputService.php b/app/classes/Framadate/Services/InputService.php index 27beb8f..c7de298 100644 --- a/app/classes/Framadate/Services/InputService.php +++ b/app/classes/Framadate/Services/InputService.php @@ -78,7 +78,8 @@ class InputService { } public function filterComment($comment) { - $filtered = filter_var($comment, FILTER_SANITIZE_STRING); + $comment = str_replace("\r\n", "\n", $comment); + $filtered = filter_var($comment, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => COMMENT_REGEX]]); return $this->returnIfNotBlank($filtered); } diff --git a/app/inc/constants.php b/app/inc/constants.php index a9cac17..f043099 100644 --- a/app/inc/constants.php +++ b/app/inc/constants.php @@ -25,8 +25,8 @@ const POLL_REGEX = '/^[a-z0-9]+$/i'; const CHOICE_REGEX = '/^[012]$/'; const NAME_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9_ -]+$/i'; const TITLE_REGEX = '/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &"\'(_)=~#{|`^@}$[\\]\\\\,;:!?.*-]+$/i'; -const DESCRIPTION_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]+$/i"; -const COMMENT_REGEX = DESCRIPTION_REGEX; +const DESCRIPTION_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]*$/i"; +const COMMENT_REGEX = "/^[áàâäãåçéèêëíìîïñóòôöõúùûüýÿæœa-z0-9\\/ &\"'(_)=~#{|`^@}$[\\]\\\\,;:!?.*\n-]+$/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]$/';