From 6dc9196c35e4adab690a97382d3d02fc9ab9122d Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 13 Dec 2015 06:30:08 +0100 Subject: [PATCH] - bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819) --- change_log.txt | 3 +++ libs/Smarty.class.php | 2 +- ...arty_internal_compile_private_foreachsection.php | 13 ++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/change_log.txt b/change_log.txt index e9472f45..91dfdd37 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.28-dev===== (xx.xx.2015) + 13.12.2015 + - bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819) + 09.12.2015 - bugix Smarty did fail under PHP 7.0.0 with use_include_path = true; diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index e4fc9473..b926e006 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.28-dev/79'; + const SMARTY_VERSION = '3.1.28-dev/80'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php index 25b35e86..50c25bdb 100644 --- a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php +++ b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php @@ -206,16 +206,15 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com */ public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) { - // make all lower case - $parameter = array_map('strtolower', $parameter); - $tag = trim($parameter[0], '"\''); - if (!isset($parameter[1]) || false === $name = $compiler->getId($parameter[1])) { + $tag = strtolower(trim($parameter[ 0 ], '"\'')); + $name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false; + if (!$name) { $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true); } + /* @var Smarty_Internal_Compile_Foreach|Smarty_Internal_Compile_Section $className */ $className = 'Smarty_Internal_Compile_' . ucfirst($tag); - if ((!isset($parameter[2]) || false === $property = $compiler->getId($parameter[2])) || - !in_array($property, $className::$nameProperties) - ) { + $property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false; + if (!$property || !in_array($property, $className::$nameProperties)) { $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true); } $tagVar = "'__smarty_{$tag}_{$name}'";