Evil e
| From: | Danilo Buerger | Date: | Thu, 08 Feb 2007 17:01:08 +0000 |
| Subject: | Evil e | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-2948@lists.php.net to get a copy of this message | ||
I suggest applying the following patch to prevent 2 problems:
a) Using the "e" pattern modifier is nearly as evil as programming cobol
b) If one of the delimiters is set to "'" it could get really ugly
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
);