From cf42bcd242e87b0e57cd8dab16f263059156018a Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Wed, 13 Oct 2010 20:26:12 +0000 Subject: [PATCH] - bugfix on template inheritance using nested eval or string resource in {extends} tags --- change_log.txt | 1 + libs/sysplugins/smarty_internal_compile_extends.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/change_log.txt b/change_log.txt index e5a8325b..76259be2 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ - bugfix removed ambiguity between ternary and stream variable in template syntax - bugfix use caching properties of template instead of smarty object when compiling child {block} - bugfix {*block}...{/block*} did throw an exception in template inheritance +- bugfix on template inheritance using nested eval or string resource in {extends} tags ===== RC4 ===== diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/libs/sysplugins/smarty_internal_compile_extends.php index 37ebf7fd..bdb9debf 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/libs/sysplugins/smarty_internal_compile_extends.php @@ -36,12 +36,16 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase { // create template object $_template = new $compiler->smarty->template_class($include_file, $this->smarty, $compiler->template); // save file dependency - $template_sha1 = sha1($_template->getTemplateFilepath()); + if (in_array($_template->resource_type,array('eval','string'))) { + $template_sha1 = sha1($include_file); + } else { + $template_sha1 = sha1($_template->getTemplateFilepath()); + } if (isset($compiler->template->properties['file_dependency'][$template_sha1])) { $this->compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"",$compiler->lex->line-1); } $compiler->template->properties['file_dependency'][$template_sha1] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp()); - $_content = $compiler->template->template_source; + $_content = substr($compiler->template->template_source,$compiler->lex->counter-1); if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) != preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) { $this->compiler->trigger_template_error('unmatched {block} {/block} pairs');