From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.2.2
PHP Bug Type:     HTTP related
Bug description:  HTML_Template_IT error with $ in values

When an IT variable is set with "$" in the value, the value isn't taken
literally.  Example:

<?php

require_once('HTML/IT.php');

$t = new IntegratedTemplate;
$t->setTemplate('{x}', TRUE, TRUE);
$t->setVariable('x', 'I have $1 in my pocket');
$t->show();

?>

The above prints "I have  in my pocket".  

A solution would be to use str_replace() instead of preg_replace() when
substituting the value.  Patch is below:

--- /usr/local/lib/php/HTML/IT.php      2002-10-14 12:05:57.000000000
-0500
+++ /usr/local/lib/php/HTML/IT.php      2002-11-04 11:11:31.000000000
-0500
@@ -414,7 +414,7 @@
         if ($this->clearCacheOnParse) {

             foreach ($this->variableCache as $name => $value) {
-                $regs[] = "@" . $this->openingDelimiter . $name .
$this->closingDelimiter . "@";
+                $regs[] = $this->openingDelimiter . $name .
$this->closingDelimiter;
                 $values[] = $value;
             }
             $this->variableCache = array();
@@ -424,7 +424,7 @@
             foreach ($this->blockvariables[$block] as $allowedvar => $v)
{

                 if (isset($this->variableCache[$allowedvar])) {
-                   $regs[]   = "@".$this->openingDelimiter . $allowedvar
. $this->closingDelimiter . "@";
+                   $regs[]   = $this->openingDelimiter . $allowedvar .
$this->closingDelimiter;
                    $values[] = $this->variableCache[$allowedvar];
                     unset($this->variableCache[$allowedvar]);
                 }
@@ -433,7 +433,7 @@

         }

-        $outer = (0 == count($regs)) ? $this->blocklist[$block] :
preg_replace($regs, $values, $this->blocklist[$block]);
+        $outer = (0 == count($regs)) ? $this->blocklist[$block] :
str_replace($regs, $values, $this->blocklist[$block]);
         $empty = (0 == count($values)) ? true : false;

         if (isset($this->blockinner[$block])) {

-- 
Edit bug report at http://bugs.php.net/?id=20392&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20392&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20392&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20392&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20392&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20392&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20392&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20392&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20392&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20392&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20392&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20392&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20392&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20392&r=isapi

Reply via email to