Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Critical bug in modifier plugin compiler.

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1160

PostPosted: Sat Dec 17, 2016 11:15 pm    Post subject: Critical bug in modifier plugin compiler. Reply with quote

Closures aren't compiled properly, resulting in empty callable's name.
Quick and dirty patch:
Code:
--- libs/sysplugins/smarty_internal_compile_private_modifier.php   2016-08-07 21:46:49.000000000 +0300
+++ libs/sysplugins/smarty_internal_compile_private_modifier.php   2016-12-18 01:46:56.000000000 +0300
@@ -48,21 +48,14 @@
                     case 1:
                         // registered modifier
                         if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
-                            $function =
-                                $compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
-                            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 . ')';
-                                } else {
-                                    $output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
-                                }
-                            }
+                            if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
+                                $output =
+                                    sprintf('call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], [ %s ])',
+                                            Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params);
                             $compiler->known_modifier_type[ $modifier ] = $type;
                             break 2;
                         }
+                        }
                         break;
                     case 2:
                         // registered modifier compiler
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP