PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_Template_IT » Bug #4392

truncate $[0-99] in the Variable?!

Details

Submitted2005-05-20 10:10 UTC
Fromfivebull at 163 dot com
Assignedpajoye
StatusBogus
PackageHTML_Template_IT
PHP Version4.3.11
OSLINUX/XP
Roadmaps(Not assigned)

Comments

[2005-05-20 10:10 UTC] fivebull at 163 dot com

Description:
------------
$[0-99] in the Variable(String) will be truncated after parse!

Reproduce code:
---------------
require_once("HTML/Template/ITX.php");

$tpl = new HTML_Template_ITX();

$tpl -> setTemplate('{TEST}');

$tpl -> setVariable('TEST', '$1, $2, $3, $i, test');

echo $tpl -> get();

Expected result:
----------------
$1, $2, $3, $i, test

Actual result:
--------------
, , , $i, test

[2005-06-21 16:02 UTC] abaqueiro at yahoo dot com

A fast fix can be escaping all the $ in the value.

in HTML/Template/IT.php
replace the function setVariable
with:
function setVariable($variable, $value = "") {

if (is_array($variable)) {
foreach(array_keys($variable) as $key){
$variable[$key] = str_replace('$','\$',$variable[$key]);
}
$this->variableCache = array_merge(
$this->variableCache, $variable
);

} else {
$value = str_replace('$','\$', $value);
$this->variableCache[$variable] = $value;

}

} // end func setVariable

[2005-06-21 18:57 UTC] pierre at dotgeek dot org

Thank you for taking the time to write to us, but this is not
a bug.

set the options preserve_data and use_preg to false. Your problem will then be solved.

--Pierre