diff options
| author | Uwe Tews <uwe.tews@googlemail.com> | 2015-08-06 01:19:11 +0200 |
|---|---|---|
| committer | Uwe Tews <uwe.tews@googlemail.com> | 2015-08-06 01:19:11 +0200 |
| commit | e1cc514a68028833e44baf4373d992f55400924b (patch) | |
| tree | c7a42d72bbe67239fe29ddd48fb8936eb5d1af72 /libs/sysplugins/smarty_internal_compile_private_modifier.php | |
| parent | ca969fe663ebc8a702b6706718ed4ea94379799a (diff) | |
| download | smarty-e1cc514a68028833e44baf4373d992f55400924b.tar.gz smarty-e1cc514a68028833e44baf4373d992f55400924b.tar.bz2 smarty-e1cc514a68028833e44baf4373d992f55400924b.zip | |
- avoid possible circular object referances caused by parser/lexer objects
Diffstat (limited to 'libs/sysplugins/smarty_internal_compile_private_modifier.php')
| -rw-r--r-- | libs/sysplugins/smarty_internal_compile_private_modifier.php | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/libs/sysplugins/smarty_internal_compile_private_modifier.php b/libs/sysplugins/smarty_internal_compile_private_modifier.php index ba03bfcf..48fe707e 100644 --- a/libs/sysplugins/smarty_internal_compile_private_modifier.php +++ b/libs/sysplugins/smarty_internal_compile_private_modifier.php @@ -20,13 +20,14 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa /** * Compiles code for modifier execution * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code + * @throws \SmartyCompilerException */ - public function compile($args, $compiler, $parameter) + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) { // check and get attributes $_attr = $this->getAttributes($compiler, $args); @@ -52,7 +53,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa $output = "{$function}({$params})"; } else { if (is_object($function[0])) { - $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')'; + $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . + $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')'; } else { $output = $function[0] . '::' . $function[1] . '(' . $params . ')'; } @@ -73,7 +75,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa // modifiercompiler plugin if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) { // check if modifier allowed - if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) { + if (!is_object($compiler->smarty->security_policy) || + $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler) + ) { $plugin = 'smarty_modifiercompiler_' . $modifier; $output = $plugin($single_modifier, $compiler); } @@ -85,7 +89,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa // modifier plugin if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) { // check if modifier allowed - if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) { + if (!is_object($compiler->smarty->security_policy) || + $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler) + ) { $output = "{$function}({$params})"; } $compiler->known_modifier_type[$modifier] = $type; @@ -96,7 +102,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa // PHP function if (is_callable($modifier)) { // check if modifier allowed - if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) { + if (!is_object($compiler->smarty->security_policy) || + $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler) + ) { $output = "{$modifier}({$params})"; } $compiler->known_modifier_type[$modifier] = $type; @@ -105,21 +113,29 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa break; case 6: // default plugin handler - if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || (is_callable($compiler->smarty->default_plugin_handler_func) && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))) { + if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || + (is_callable($compiler->smarty->default_plugin_handler_func) && + $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER)) + ) { $function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0]; // check if modifier allowed - if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) { + if (!is_object($compiler->smarty->security_policy) || + $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler) + ) { if (!is_array($function)) { $output = "{$function}({$params})"; } else { if (is_object($function[0])) { - $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')'; + $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . + $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')'; } else { $output = $function[0] . '::' . $function[1] . '(' . $params . ')'; } } } - if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) { + if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || + isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) + ) { // was a plugin $compiler->known_modifier_type[$modifier] = 4; } else { @@ -130,7 +146,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa } } if (!isset($compiler->known_modifier_type[$modifier])) { - $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno); + $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", null, true); } } |
