From 1ac53a5aad5bb8daee4133a0de363869a2fcb2a4 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 16 Apr 2014 16:23:36 +0300 Subject: [PATCH] dont strip tags --- application/Espo/Services/Record.php | 36 +++++++++---------- .../res/templates/fields/text/detail.tpl | 2 +- frontend/client/src/view-helper.js | 3 +- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index bdec2e22c2..021f320199 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -197,36 +197,34 @@ class Record extends \Espo\Core\Services\Base protected function stripTags($string) { return strip_tags($string, '


    • '); + } + + protected function filterInputField($field, $value) + { + if (in_array($field, $this->notFilteringFields)) { + return $value; + } + $methodName = 'filterInputField' . ucfirst($field); + if (method_exists($this, $methodName)) { + $value = $this->$methodName($value); + } + return $value; } protected function filterInput(&$data) - { - + { foreach ($data as $key => $value) { if (is_array($data[$key])) { foreach ($data[$key] as $i => $v) { - if (in_array($i, $this->notFilteringFields)) { - continue; - } - if (is_string($data[$key][$i])) { - $data[$key][$i] = $this->stripTags($data[$key][$i]); - } + $data[$key][$i] = $this->filterInputField($i, $data[$key][$i]); } } else if ($data[$key] instanceof \stdClass) { $propertyList = get_object_vars($data[$key]); foreach ($propertyList as $property) { - if (in_array($property, $this->notFilteringFields)) { - continue; - } - if (is_string($data[$key]->$property)) { - $data[$key]->$property = $this->stripTags($data[$key]->$property); - } + $data[$key]->$property = $this->filterInputField($property, $data[$key]->$property); } - } else if (is_string($data[$key])) { - if (in_array($key, $this->notFilteringFields)) { - continue; - } - $data[$key] = $this->stripTags($data[$key]); + } else { + $data[$key] = $this->filterInputField($key, $data[$key]); } } } diff --git a/frontend/client/res/templates/fields/text/detail.tpl b/frontend/client/res/templates/fields/text/detail.tpl index 428bb2ef73..f419a58bfb 100644 --- a/frontend/client/res/templates/fields/text/detail.tpl +++ b/frontend/client/res/templates/fields/text/detail.tpl @@ -1 +1 @@ -{{{breaklines value}}} +{{breaklines value}} diff --git a/frontend/client/src/view-helper.js b/frontend/client/src/view-helper.js index 49757f2997..6308ce13b3 100644 --- a/frontend/client/src/view-helper.js +++ b/frontend/client/src/view-helper.js @@ -127,8 +127,7 @@ }); Handlebars.registerHelper('breaklines', function (text) { - text = text || ''; - text = text.toString(); + text = Handlebars.Utils.escapeExpression(text || ''); text = text.replace(/(\r\n|\n|\r)/gm, '
      '); return new Handlebars.SafeString(text); });