From dc164c4d7917a5135da8efd9fbb10cc04016d507 Mon Sep 17 00:00:00 2001 From: Paul B Date: Mon, 15 Apr 2019 15:00:00 +0200 Subject: [PATCH] fix(admin/add_column): stop modifying user input in stored data An [earlier change](https://framagit.org/framasoft/framadate/framadate/commit/892fa11373bd0781b7916a6c97d7f354ba51f428) modifed the user's input when creating new columns in an existing Poll. Indeed all `,` comma were replaced by `-` dashes and the user inputs was saved as such. It seems the rational behind it was to keep the existing "formatting" of log messages where different elements were separated by commas. This commit makes sure to not strip the users' data but only the logged message. Fixes #384 --- adminstuds.php | 4 ++-- app/classes/Framadate/Services/AdminPollService.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 94c5648..26a2e28 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -467,10 +467,10 @@ if (isset($_POST['confirm_add_column'])) { if ($poll->format === 'D') { $date = DateTime::createFromFormat(__('Date', 'Y-m-d'), $_POST['newdate'])->setTime(0, 0, 0); $time = $date->getTimestamp(); - $newmoment = str_replace(',', '-', strip_tags($_POST['newmoment'])); + $newmoment = strip_tags($_POST['newmoment']); $adminPollService->addDateSlot($poll_id, $time, $newmoment); } else { - $newslot = str_replace(',', '-', strip_tags($_POST['choice'])); + $newslot = strip_tags($_POST['choice']); $adminPollService->addClassicSlot($poll_id, $newslot); } diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php index 51760f9..62912c8 100644 --- a/app/classes/Framadate/Services/AdminPollService.php +++ b/app/classes/Framadate/Services/AdminPollService.php @@ -200,7 +200,7 @@ class AdminPollService { * @throws \Doctrine\DBAL\ConnectionException */ public function addDateSlot($poll_id, $datetime, $new_moment) { - $this->logService->log('ADD_COLUMN', 'id:' . $poll_id . ', datetime:' . $datetime . ', moment:' . $new_moment); + $this->logService->log('ADD_COLUMN', 'id:' . $poll_id . ', datetime:' . $datetime . ', moment:' . str_replace(',', '-', $new_moment)); try { $slots = $this->slotRepository->listByPollId($poll_id); @@ -252,7 +252,7 @@ class AdminPollService { * @throws \Doctrine\DBAL\DBALException */ public function addClassicSlot($poll_id, $title) { - $this->logService->log('ADD_COLUMN', 'id:' . $poll_id . ', title:' . $title); + $this->logService->log('ADD_COLUMN', 'id:' . $poll_id . ', title:' . str_replace(',', '-', $title)); $slots = $this->slotRepository->listByPollId($poll_id);