diff --git a/NEWS b/NEWS index 46702b23..94db98e5 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,3 @@ - - corrected output with smarty comments (Monte) - corrected output with {strip} and PHP tag newlines (Monte) - added possibility to register function-callbacks as "array(&$obj, 'method)" this affects register_function(), -block, -compiler_function, -modifier, diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 63f1a1f0..e49228da 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -238,18 +238,8 @@ class Smarty_Compiler extends Smarty { } /* Annihilate the comments. */ - - $_comment_search = array( - "!{$ldq}\*.*?\*{$rdq}!s", // get all onto one line - "!(\r|\r\n|\n)%%%SMARTY_COMMENT%%%(\r|\r\n|\n)!", // remove CR if on one line - '!%%%SMARTY_COMMENT%%%!'); // remove remaining comments - $_comment_replace = array( - '%%%SMARTY_COMMENT%%%', - '\\1', - ''); - - $template_source = preg_replace($_comment_search, - $_comment_replace, + $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", + "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'", $template_source); /* Pull out the literal blocks. */ @@ -390,6 +380,10 @@ class Smarty_Compiler extends Smarty { function _compile_tag($template_tag) { + /* Matched comment. */ + if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*') + return ''; + /* Split tag into two three parts: command, command modifiers and the arguments. */ if(! preg_match('/^(?:(' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '|' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))