cvs: pear /HTML_Template_IT IT.php /HTML_Template_IT/tests IT_bugs_testcase.php /HTML_Template_IT/tests/templates bug_9853_01.tpl bug_9853_02.tpl

From: Date: Mon, 12 Feb 2007 19:55:57 +0000
Subject: cvs: pear /HTML_Template_IT IT.php /HTML_Template_IT/tests IT_bugs_testcase.php /HTML_Template_IT/tests/templates bug_9853_01.tpl bug_9853_02.tpl
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44631@lists.php.net to get a copy of this message
dsp Mon Feb 12 19:55:57 2007 UTC Added files: /pear/HTML_Template_IT/tests/templates bug_9853_01.tpl bug_9853_02.tpl Modified files: /pear/HTML_Template_IT IT.php /pear/HTML_Template_IT/tests IT_bugs_testcase.php Log: Fix bug #9853. As dots are allowed as modifiers we have to quote found placeholders and blocknames before reusing them as patterns http://cvs.php.net/viewvc.cgi/pear/HTML_Template_IT/IT.php?r1=1.23&r2=1.24&diff_format=u Index: pear/HTML_Template_IT/IT.php diff -u pear/HTML_Template_IT/IT.php:1.23 pear/HTML_Template_IT/IT.php:1.24 --- pear/HTML_Template_IT/IT.php:1.23 Thu Feb 1 16:53:35 2007 +++ pear/HTML_Template_IT/IT.php Mon Feb 12 19:55:57 2007 @@ -1,7 +1,8 @@ <?php // // +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2005 Ulf Wendel, Pierre-Alain Joye | +// | Copyright (c) 1997-2007 Ulf Wendel, Pierre-Alain Joye, | +// | David Soria Parra | // +----------------------------------------------------------------------+ // | This source file is subject to the New BSD license, That is bundled | // | with this package in the file LICENSE, and is available through | @@ -13,9 +14,10 @@ // +----------------------------------------------------------------------+ // | Author: Ulf Wendel <ulf.wendel@phpdoc.de> | // | Pierre-Alain Joye <pajoye@php.net> | +// | David Soria Parra <dsp@php.net> | // +----------------------------------------------------------------------+ // -// $Id: IT.php,v 1.23 2007/02/01 16:53:35 dsp Exp $ +// $Id: IT.php,v 1.24 2007/02/12 19:55:57 dsp Exp $ // require_once 'PEAR.php'; @@ -117,7 +119,7 @@ * </code> * * @author Ulf Wendel <uw@netuse.de> - * @version $Id: IT.php,v 1.23 2007/02/01 16:53:35 dsp Exp $ + * @version $Id: IT.php,v 1.24 2007/02/12 19:55:57 dsp Exp $ * @access public * @package HTML_Template_IT */ @@ -946,8 +948,8 @@ foreach ($inner as $k => $name) { $pattern = sprintf( '@<!--\s+BEGIN\s+%s\s+-->(.*)<!--\s+END\s+%s\s+-->@sm', - $name, - $name + preg_quote($name), + preg_quote($name) ); $this->blocklist[$blockname] = preg_replace( @@ -1013,7 +1015,7 @@ */ function _addPregDelimiters($str) { - return '@' . $str . '@'; + return '@' . preg_quote($str) . '@'; } /** http://cvs.php.net/viewvc.cgi/pear/HTML_Template_IT/tests/IT_bugs_testcase.php?r1=1.2&r2=1.3&diff_format=u Index: pear/HTML_Template_IT/tests/IT_bugs_testcase.php diff -u pear/HTML_Template_IT/tests/IT_bugs_testcase.php:1.2 pear/HTML_Template_IT/tests/IT_bugs_testcase.php:1.3 --- pear/HTML_Template_IT/tests/IT_bugs_testcase.php:1.2 Thu Feb 1 16:53:35 2007 +++ pear/HTML_Template_IT/tests/IT_bugs_testcase.php Mon Feb 12 19:55:57 2007 @@ -84,6 +84,41 @@ $this->assertEquals('{Bakken} Soria Joye', trim($this->tpl->get())); } + + function testBug9853 () + { + $this->tpl->loadTemplatefile("bug_9853_01.tpl", true, true); + + $this->tpl->setVariable("VAR" , "Ok !"); + $this->tpl->parse("foo1"); + + $this->tpl->setVariable("VAR" , "Ok !"); + $this->tpl->parse("foo2"); + + $this->tpl->setVariable("VAR." , "Ok !"); + $this->tpl->setVariable("VAR2" , "Okay"); + $this->tpl->parse("bar"); + + $this->tpl->parse(); + $output01 = $this->tpl->get(); + + $this->tpl->loadTemplatefile("bug_9853_02.tpl", true, true); + + $this->tpl->setVariable("VAR" , "Ok !"); + $this->tpl->parse("foo."); + + $this->tpl->setVariable("VAR" , "Ok !"); + $this->tpl->parse("foo2"); + + $this->tpl->setVariable("VAR." , "Ok !"); + $this->tpl->setVariable("VAR2" , "Okay"); + $this->tpl->parse("bar"); + + $this->tpl->parse(); + $output02 = $this->tpl->get(); + + $this->assertEquals($output01, $output02); + } } ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/HTML_Template_IT/tests/templates/bug_9853_01.tpl?view=markup&rev=1.1 Index: pear/HTML_Template_IT/tests/templates/bug_9853_01.tpl +++ pear/HTML_Template_IT/tests/templates/bug_9853_01.tpl ############ TEST ################ before foo1 bloc <!-- BEGIN foo1 --> In foo1...{VAR} <!-- END foo1 --> after foo1 bloc before foo2 bloc <!-- BEGIN foo2 --> In foo2...{VAR} <!-- END foo2 --> after foo2 bloc before bar bloc <!-- BEGIN bar --> In bar...{VAR.} In bar...{VAR2} <!-- END bar --> after bar bloc http://cvs.php.net/viewvc.cgi/pear/HTML_Template_IT/tests/templates/bug_9853_02.tpl?view=markup&rev=1.1 Index: pear/HTML_Template_IT/tests/templates/bug_9853_02.tpl +++ pear/HTML_Template_IT/tests/templates/bug_9853_02.tpl ############ TEST ################ before foo1 bloc <!-- BEGIN foo. --> In foo1...{VAR} <!-- END foo. --> after foo1 bloc before foo2 bloc <!-- BEGIN foo2 --> In foo2...{VAR} <!-- END foo2 --> after foo2 bloc before bar bloc <!-- BEGIN bar --> In bar...{VAR.} In bar...{VAR2} <!-- END bar --> after bar bloc

« previous php.pear.cvs (#44631) next »