From 8ef0c125c51fe84af79ec9c120fd2dc16989671e Mon Sep 17 00:00:00 2001 From: Maximilian Becker Date: Tue, 14 Jun 2022 12:05:32 +0200 Subject: [PATCH] T&A: fix 30658 #4553 (+copyright) --- .../classes/class.assLongMenuGUI.php | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php index b6c985a747f8..41a339527a4a 100644 --- a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php +++ b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php @@ -1,5 +1,20 @@ object->setLongMenuTextValue(ilUtil::stripSlashes($_POST['longmenu_text'])); - $this->object->setAnswers(json_decode(ilUtil::stripSlashes($_POST['hidden_text_files']))); - $this->object->setCorrectAnswers(json_decode( - ilUtil::stripSlashes($_POST['hidden_correct_answers']) - )); - $this->object->setAnswerType(ilUtil::stripSlashes((string) $_POST['long_menu_type'])); + $this->object->setLongMenuTextValue(ilUtil::stripSlashesRecursive($_POST['longmenu_text'])); + $this->object->setAnswers($this->trimArrayRecursive(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_text_files'])))); + $this->object->setCorrectAnswers($this->trimArrayRecursive(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_correct_answers'])))); + $this->object->setAnswerType(ilUtil::stripSlashesRecursive($_POST['long_menu_type'])); $this->object->setQuestion($_POST['question']); $this->object->setLongMenuTextValue($_POST["longmenu_text"]); $this->object->setMinAutoComplete((int) $_POST["min_auto_complete"]); @@ -99,6 +112,22 @@ public function writeQuestionSpecificPostData(ilPropertyFormGUI $form) : void $this->saveTaxonomyAssignments(); } + protected function trimArrayRecursive(array $data) + { + if (is_array($data)) { + foreach ($data as $k => $v) { + if (is_array($v)) { + $data[$k] = $this->trimArrayRecursive($v); + } else { + $data[$k] = trim($v); + } + } + } else { + $data = trim($data); + } + return $data; + } + protected function editQuestion(ilPropertyFormGUI $form = null) : void { if ($form === null) {