From 820e0e70d8b228789a8032611638fb929b645d98 Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Tue, 7 Feb 2012 18:54:06 +0000 Subject: [PATCH] - bugfix increase entropy of internal function names in compiled and cached template files (Forum Topic 20996) --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_compile_include.php | 2 +- libs/sysplugins/smarty_internal_template.php | 6 ++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/change_log.txt b/change_log.txt index 15e5b7b6..606638a3 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== +07.02.2012 +- bugfix increase entropy of internal function names in compiled and cached template files (Forum Topic 20996) + 06.02.2012 - improvement stream_resolve_include_path() added to Smarty_Internal_Get_Include_Path (Forum Topic 20980) - bugfix fetch('extends:foo.tpl') always yielded $source->exists == true (Forum Topic 20980) diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index b18d52dd..43a144f9 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -132,7 +132,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { if (!isset($compiler->smarty->merged_templates_func[$tpl_name]) || $compiler->inheritance) { $tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id); // save unique function name - $compiler->smarty->merged_templates_func[$tpl_name]['func'] = $tpl->properties['unifunc'] = 'content_'.uniqid('', false); + $compiler->smarty->merged_templates_func[$tpl_name]['func'] = $tpl->properties['unifunc'] = 'content_'. str_replace('.', '_', uniqid('', true)); // use current nocache hash for inlined code $compiler->smarty->merged_templates_func[$tpl_name]['nocache_hash'] = $tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; if ($compiler->template->caching) { diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index a34e247e..447ff3c9 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -221,7 +221,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { return false; } $this->properties['cache_lifetime'] = $this->cache_lifetime; - $this->properties['unifunc'] = 'content_' . uniqid('', false); + $this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true)); $content = $this->createTemplateCodeFrame($content, true); $_smarty_tpl = $this; eval("?>" . $content); @@ -390,12 +390,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { } $this->properties['version'] = Smarty::SMARTY_VERSION; if (!isset($this->properties['unifunc'])) { - $this->properties['unifunc'] = 'content_' . uniqid('', false); + $this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true)); } if (!$this->source->recompiled) { $output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . ',' . ($cache ? 'true' : 'false') . "); /*/%%SmartyHeaderCode%%*/?>\n"; - } - if (!$this->source->recompiled) { $output .= 'properties['unifunc'] . '\')) {function ' . $this->properties['unifunc'] . '($_smarty_tpl) {?>'; } $output .= $plugins_string;