diff --git a/.travis.yml b/.travis.yml index baca1979..824aac87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 5.2 - 5.3 - 5.4 - 5.5 diff --git a/change_log.txt b/change_log.txt index 760e4f8a..622b6b41 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.24.dev ===== (xx.xx.2015) + 21.05.2015 + - bugfix broken PHP 5.2 compatibility when compiling php_handling = $compiler->smarty->php_handling; } if ($this->php_handling == Smarty::PHP_REMOVE) { - $output = preg_replace(array('#^(<\?(?:php|=)?)|(<%)|()#', '#(\?>)|(%>)|(<\/script>)$#'), '', $_attr['code']); + $output = preg_replace(array('#^(<\?(?:php|=)?)|(<%)|()#', + '#(\?>)|(%>)|(<\/script>)$#'), '', $_attr['code']); $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output)); return ''; } elseif ($this->php_handling == Smarty::PHP_QUOTE) { - $output = preg_replace_callback(array('#^(<\?(?:php|=)?)|(<%)|()#', '#(\?>)|(%>)|(<\/script>)$#'), function ($match) {return htmlspecialchars($match[0], ENT_QUOTES);}, $_attr['code']); + $output = preg_replace_callback(array('#^(<\?(?:php|=)?)|(<%)|()#', + '#(\?>)|(%>)|(<\/script>)$#'), array($this, + 'quote'), $_attr['code']); $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output)); return ''; } elseif ($this->php_handling == Smarty::PHP_PASSTHRU || ($_attr['type'] == 'asp' && !$this->asp_tags) || $_attr['type'] == 'unmatched') { @@ -86,7 +90,17 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", $compiler->lex->taglineno); } } - return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array(''), $_attr['code']); + return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", + "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array(''), $_attr['code']); } } + + /* + * Call back function for $php_handling = PHP_QUOTE + * + */ + private function quote($match) + { + return htmlspecialchars($match[0], ENT_QUOTES); + } }