Re: Evil e

From: Date: Thu, 08 Feb 2007 20:07:55 +0000
Subject: Re: Evil e
References: 1  Groups: php.smarty.dev php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2949@lists.php.net to get a copy of this message
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
COBOL is nice , definitively structured. modifier e is worse than evil.
b) If one of the delimiters is set to "'" it could get really ugly
Hears nice to forbid it or at least nicely do nothing on this I did not look into the patch just react to the concepts here. -- toggg
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
        );


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