Evil e
Danilo Buerger <[email protected]> Thu, 08 Feb 2007 18:01:08 +0100
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <[email protected]> |
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
> );
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php