Bug in CVS HEAD

[email protected] (Danilo Buerger) Fri, 23 Feb 2007 16:53:30 +0100
Newsgroups php.smarty.dev
Message-ID <[email protected]>
Hey list,

Smarty goes berserk when trying to embed php code:
Having php_handling == SMARTY_PHP_PASSTHRU :

--- template ---
{$smarty.now}<?php echo time(); ?>

--- compile ---
<?php echo time(); ?>
<?php echo '<?' ?>
php echo '<?php echo '<?' ?>
php'; ?>
  echo time(); <?php echo '<?' ?>
php echo '?>'; ?>

--- expected compile ---
<?php echo time(); ?>
<?php echo '<?php'; ?>
  echo time(); <?php echo '?>'; ?>

And when having php_handling == SMARTY_PHP_ALLOW :

--- compile ---
<?php echo time(); ?>
<?php echo '<?' ?>
php echo time(); ?>

--- expected compile ---
<?php echo time(); ?>
<?php echo time(); ?>

Here is the fix:

Index: Smarty_Compiler.class.php
===================================================================
RCS file: /repository/smarty/libs/Smarty_Compiler.class.php,v
retrieving revision 1.389
diff -r1.389 Smarty_Compiler.class.php
357c357
<
---
 >
372c372
<         $compiled_content .= $text_blocks[$i];
---
 >         $compiled_content .= str_replace('<?',$tmp_id,$text_blocks[$i]);