From 369b44d94ab07a2899c4b18d2b275ab4244e0ab0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 27 Dec 2016 04:46:36 -0500 Subject: [PATCH] Fix unsetting template objects Fixes compatibility with some plugins e.g. kolab_addressbook which call parse() method (for sub-templates) while parsing the main template --- program/include/rcmail_output_html.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 583ee2eb2..fd4b91431 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -1012,18 +1012,13 @@ EOF; * with the appropriate content * * @param string $input Input string to parse - * @param bool $reset Reset stored objects * * @return string Altered input string * @todo Use DOM-parser to traverse template HTML * @todo Maybe a cache. */ - protected function parse_xml($input, $reset = true) + protected function parse_xml($input) { - if ($reset) { - $this->objects = array(); - } - return preg_replace_callback('/]|\\\\>)+)(?/Ui', array($this, 'xml_command'), $input); } @@ -1123,7 +1118,7 @@ EOF; $incl = file_get_contents($path); } $incl = $this->parse_conditions($incl); - $incl = $this->parse_xml($incl, false); + $incl = $this->parse_xml($incl); $incl = $this->fix_paths($incl); $this->base_path = $old_base_path; return $incl; @@ -1296,12 +1291,12 @@ EOF; { // insert objects' contents foreach ($this->objects as $key => $val) { - $output = str_replace($key, $val, $output); + $output = str_replace($key, $val, $output, $count); + if ($count) { + $this->objects[$key] = null; + } } - // reset objects - $this->objects = array(); - // make sure all
tags have a valid request token $output = preg_replace_callback('/]+)>/Ui', array($this, 'alter_form_tag'), $output);