From de892651c20259bcf036539e2837c9164667876b Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 20 Apr 2015 22:59:45 +0200 Subject: [PATCH] - bugfix at a template function containing nocache code a parmeter could overwrite a template variable of same name --- change_log.txt | 3 +++ libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_compile_function.php | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/change_log.txt b/change_log.txt index 5a937a27..6d65c732 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.22-dev ===== (xx.xx.2015) + 20.04.2015 + - bugfix at a template function containing nocache code a parmeter could overwrite a template variable of same name + 27.03.2015 - bugfix Smarty_Security->allow_constants=false; did also disable true, false and null (change of 16.03.2015) - improvement added a whitelist for trusted constants to security Smarty_Security::$trusted_constants (forum topic 25471) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index d4e50af4..76ad37f1 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.22-dev/17'; + const SMARTY_VERSION = '3.1.22-dev/18'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index d90665eb..57054851 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -156,6 +156,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase } $output .= "ob_start();\n"; $output .= $_paramsCode; + $output .= "\$_smarty_tpl->properties['saved_tpl_vars'][] = \$_smarty_tpl->tpl_vars;\n"; $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}"; $output .= "\$params = var_export(\$params, true);\n"; $output .= "echo \"/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n"; $output .= "\\\$_smarty_tpl->tpl_vars = \\\$saved_tpl_vars;?>\n"; $output .= "/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/\";\n?>"; - $output .= "template->properties['nocache_hash']}', \$_smarty_tpl->properties['nocache_hash'], ob_get_clean());\n}\n}\n"; + $output .= "template->properties['nocache_hash']}', \$_smarty_tpl->properties['nocache_hash'], ob_get_clean());\n"; + $output .= "\$_smarty_tpl->tpl_vars = array_pop(\$_smarty_tpl->properties['saved_tpl_vars']);\n}\n}\n"; $output .= "/*/ {$_funcName}_nocache */\n\n"; $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));