Re: [SMARTY-DEV] Evil e

From: Date: Thu, 08 Feb 2007 22:59:42 +0000
Subject: Re: [SMARTY-DEV] Evil e
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2951@lists.php.net to get a copy of this message
On Thu, Feb 08, 2007 at 06:01:08PM +0100, Danilo Buerger wrote: > I suggest applying the following patch to prevent 2 problems: > a) Using the "e" pattern modifier is nearly as evil as programming cobol /e is evil, so is create_function(). if we want to clean this up, we should add a method like replace_special_blocks() to Smarty_Compiler and use this as callback together with preg_replace_callback(). > b) If one of the delimiters is set to "'" it could get really ugly good point. if there are more places in the compiler that cause problems we should also add to the manual of $smarty->(left|right)_delimiter that certain strings are not supported. > Index: Smarty_Compiler.class.php > =================================================================== > RCS file: /repository/smarty/libs/Smarty_Compiler.class.php,v > retrieving revision 1.386 > diff -r1.386 Smarty_Compiler.class.php > 268,273c270,279 > < $source_content = preg_replace($search.'e', "'" > < . > $this->_quote_replace($this->left_delimiter) . 'php' > < . "' . str_repeat(\"\n\", > substr_count('\\0', \"\n\")) .'" > < . > $this->_quote_replace($this->right_delimiter) > < . "'" > < , $source_content); > --- > > $source_content = preg_replace_callback( > > $search, > > create_function( > > '$matches', > > 'return \'' . addslashes($this->left_delimiter) . > > 'php' > > . '\' . str_repeat("\n", substr_count($matches[0], > "\n")) . \'' > > . addslashes($this->right_delimiter) . '\';' > > ), > > $source_content > > ); > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.dev (#2951) next »