Bugs item #542612, was opened at 2002-04-12 05:10
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=403611&aid=542612&group_id=31885
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Scott Lahteine (slurslee)
>Assigned to: Richard Archer (richardarcher)
Summary: backslashes lost by subst()
Initial Comment:
The subst() function in template.inc uses
preg_replace to merge variables with page
content. The trouble with preg_replace is that its
second argument, the replacement string, is
treated in a "grep-like" way, such that the
backslash character has a special meaning. So
every backslash needs to be doubled before doing
the replacement, or else every other one will be
stripped out.
To fix the preg_replace problem I changed the
subst() function like so:
function subst($handle) {
if (!$this->loadfile($handle)) {
$this->halt("subst: unable to load $handle.");
return false;
}
$str = $this->get_var($handle);
// THESE LINES WERE ADDED BY ME
foreach ($this->varvals as $k=>$v)
$this->varvalsfixed[$k] = preg_replace('/\/', '\\',
$v);
// AND I CHANGED THIS LINE TOO
$str = @preg_replace($this->varkeys, $this->
varvalsfixed, $str);
return $str;
}
----------------------------------------------------------------------
>Comment By: Richard Archer (richardarcher)
Date: 2002-04-25 22:57
Message:
Logged In: YES
user_id=279311
This doesn't fix the complete problem... that of $1 going
missing too.
It did, however give me the hint I needed to fix this
problem properly.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=403611&aid=542612&group_id=31885
|