logo       

Re: Evil e: msg#00008

Subject: Re: Evil e
You both have some valid points. However, since the API isnt going to change for 2.6.x (i guess). These issues should be fixed the easy way. In this case my patch could be applied or $this->_quote_replace() could be replaced with addslashes() to make this work with all delimiters.

boots schrieb:
--- messju mohr <messju@xxxxxxxxxxxxxxxxxx> wrote:
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().

This is indeed better for this circumstance but I disagree with the hypothesis.
Eval is useful, though of course it can be dangerous and it does have the
*potential* for danger here.


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.

Agreed. And we should maybe make the compiler forbid them as well. Or we can
create getters/setters for the delims and enforce it there.


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
        );




____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091


--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe