Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Critical bug in modifier plugin compiler.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

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
Eithan
Smarty n00b


Joined: 04 Jun 2018
Posts: 1

PostPosted: Mon Jun 04, 2018 10:46 am    Post subject: Reply with quote

Just what I was searching for..
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Jun 04, 2018 4:58 pm    Post subject: Reply with quote

Elaborate, please. The bug was fixed years ago.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Jun 06, 2018 3:05 pm    Post subject: Reply with quote

Closing as outdated to prevent spam.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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