PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_Template_IT » Bug #7962

$[0-9][0-9] in replacements get lost

Details

Submitted2006-06-22 09:16 UTC
Fromflorian dot schoeppe at gmx dot net
Assignedpajoye
StatusBogus
PackageHTML_Template_IT
PHP VersionIrrelevant
OSAny
Roadmaps(Not assigned)

Comments

[2006-06-22 09:16 UTC] florian dot schoeppe at gmx dot net

Description:
------------
Patched lines 418 and 430 (Escaping $ sign, and \\ (actually another "bad string")):

if ($this->clearCacheOnParse) {

foreach ($this->variableCache as $name => $value) {
$regs[] = "@" . $this->openingDelimiter . $name . $this->closingDelimiter . "@";
$values[] = str_replace('$', '\$', str_replace(chr(92), chr(92) . chr(92), $value));
}
$this->variableCache = array();

} else {

foreach ($this->blockvariables[$block] as $allowedvar => $v) {

if (isset($this->variableCache[$allowedvar])) {
$regs[] = "@".$this->openingDelimiter . $allowedvar . $this->closingDelimiter . "@";
$values[] = str_replace('$', '\$', str_replace(chr(92), chr(92) . chr(92), $this->variableCache[$allowedvar]));
unset($this->variableCache[$allowedvar]);
}

}

}

Test script:
---------------
$tpl = new IntegratedTemplate('./');
$tpl->loadTemplateFile('test.tpl', true, true);
$tpl->touchBlock('__global__');
$tpl->setVariable('test', 'This should be 1200 Dollar: $1200');
$tpl->show();

Expected result:
----------------
Expected output:
This should be 1200 Dollar: $1200

Actual result:
--------------
Actual output:
This should be 1200 Dollar: 00