Skip to content

Commit

Permalink
fix(textareafield): problem with backslashes rendering
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Nov 23, 2018
1 parent 4588efa commit 43fdbe1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion inc/fields/textareafield.class.php
Expand Up @@ -115,7 +115,7 @@ public function prepareQuestionInputForSave($input) {
}

public function getValueForTargetText($richText) {
return str_replace("\r\n", '\r\n', Toolbox::addslashes_deep($this->value));
return $this->value;
}

public static function getJSFields() {
Expand Down
2 changes: 1 addition & 1 deletion inc/form.class.php
Expand Up @@ -1205,7 +1205,7 @@ public function saveForm($input) {

if (!$valid) {
// Save answers in session to display it again with the same values
$_SESSION['formcreator']['data'] = $input;
$_SESSION['formcreator']['data'] = Toolbox::stripslashes_deep($input);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions inc/form_answer.class.php
Expand Up @@ -1068,7 +1068,7 @@ public function getAnswers($formAnswerId) {
$answers = $answer->find("`plugin_formcreator_forms_answers_id` = '$formAnswerId'");
$answers_values = [];
foreach ($answers as $found_answer) {
$answers_values['formcreator_field_' . $found_answer['plugin_formcreator_questions_id']] = stripslashes($found_answer['answer']);
$answers_values['formcreator_field_' . $found_answer['plugin_formcreator_questions_id']] = $found_answer['answer'];
}
return $answers_values;
}
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public function getFullForm($richText = false) {

$question_no = 0;
$output = '';
$eol = "\n";
$eol = '\n';

if ($richText) {
$output .= '<h1>' . __('Form data', 'formcreator') . '</h1>';
Expand Down
2 changes: 1 addition & 1 deletion inc/targetbase.class.php
Expand Up @@ -976,7 +976,7 @@ protected function parseTags($content, PluginFormcreatorForm_Answer $formanswer,
}

$content = str_replace('##question_' . $questionId . '##', Toolbox::addslashes_deep($name), $content);
$content = str_replace('##answer_' . $questionId . '##', $value, $content);
$content = str_replace('##answer_' . $questionId . '##', Toolbox::addslashes_deep($value), $content);
foreach ($fields[$questionId]->getDocumentsForTarget() as $documentId) {
$this->addAttachedDocument($documentId);
}
Expand Down
4 changes: 2 additions & 2 deletions inc/targetticket.class.php
Expand Up @@ -1097,13 +1097,13 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
$data['name'] = $this->prepareTemplate(
$this->fields['name'],
$formanswer,
true
false
);
$data['name'] = $this->parseTags($data['name'], $formanswer);
$data['content'] = $this->prepareTemplate(
$this->fields['content'],
$formanswer,
false
$richText
);

$data['content'] = $this->parseTags($data['content'], $formanswer, $richText);
Expand Down
3 changes: 1 addition & 2 deletions tests/suite-unit/PluginFormcreatorTargetTicket.php
Expand Up @@ -307,8 +307,7 @@ public function providerPrepareTemplate() {
$sectionName = $section->fields['name'];
$questionTag = '##question_' . $question->getID() . '##';
$answerTag = '##answer_' . $question->getID() . '##';
$eolSimple = "\n";
$eolRich = "\r\n";
$eolSimple = '\n';
// 2 expected values
// 0 : Rich text mode disabled
// 1 : Rich text mode enabled
Expand Down

0 comments on commit 43fdbe1

Please sign in to comment.