[Phplib-trackers] [ phplib-Bugs-542612 ] backslashes lost by subst()
Brought to you by:
nhruby,
richardarcher
|
From: <no...@so...> - 2002-04-11 19:10:26
|
Bugs item #542612, was opened at 2002-04-11 12:10 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=403611&aid=542612&group_id=31885 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Scott Lahteine (slurslee) Assigned to: Nobody/Anonymous (nobody) 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; } ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=403611&aid=542612&group_id=31885 |