From c6501b6a8842ce1e3c85b0d29ff12afb71980030 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 4 Apr 2016 20:57:01 +0000 Subject: [PATCH] Avoid double encoding when not parsing html styles --- etemplate/inc/class.bo_merge.inc.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 306ed55ae5..0178bd9c0c 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -204,7 +204,7 @@ abstract class bo_merge $contact = $this->contacts->read($contact, $ignore_acl); } if (!is_array($contact)) return array(); - + $replacements = array(); foreach(array_keys($this->contacts->contact_fields) as $name) { @@ -1012,7 +1012,7 @@ abstract class bo_merge continue; } // decode html entities back to utf-8 - + if (is_string($value) && (strpos($value,'&') !== false) && $this->parse_html_styles) { $value = html_entity_decode($value,ENT_QUOTES,$charset); @@ -1118,7 +1118,10 @@ abstract class bo_merge } // now decode &, < and >, which need to be encoded as entities in xml // Check for encoded >< getting double-encoded - $replacements = str_replace(array('&',"\r","\n",'&lt;','&gt;'),array('&','',$break,'<','>'),$replacements); + if($this->parse_html_styles) + { + $replacements = str_replace(array('&',"\r","\n",'&lt;','&gt;'),array('&','',$break,'<','>'),$replacements); + } } if ($mimetype == 'application/x-yaml') {