Req #15993 [Opn->Csd]: Collisions between template variable names and javascript
| From: | cweiske@php.net | Date: | Sat, 19 Sep 2009 07:00:40 +0000 |
| Subject: | Req #15993 [Opn->Csd]: Collisions between template variable names and javascript | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-1674@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=15993&edit=1
ID: 15993
Updated by: cweiske@php.net
Reported By: fsb at thefsb dot org
Summary: Collisions between template variable names and
javascript
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: HTML_Template_PHPLIB
Operating System: OS X 10.5 / FreeBSD 7.1
Package Version: 1.4.0
PHP Version: 5.2.5
-Assigned To:
+Assigned To: cweiske
Roadmap Versions:
New Comment:
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cweiske
This bug has been fixed in SVN.
If this was a documentation problem, the fix will appear on
pear.php.net by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should
be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.
Will be in 1.5.0
Previous Comments:
------------------------------------------------------------------------
[2009-08-19 14:09:38] thefsb
on second thoughts, the line in setIllegals() in my proposed changes
should
probably be:
$this->illegals = preg_quote($illegals, '/');
------------------------------------------------------------------------
[2009-03-08 17:48:11] thefsb
Description:
------------
Problems sometimes arise if javascript in a template string matches the
pattern for a replacement, e.g.:
<a href="javascript:my_fn({firstkey:12,secondkey:'String'})">
var myRe = new RegExp("\d{1,5}");
Existing workarounds, e.g. setUnknowns('keep'), are not always
convenient. Another possibility is to allow the user to
expand the set of illegal characters in template variable names. Here
is a
diff of a possible implementation:
79a80,81
> var $illegals = '';
>
213a216,220
> function setIllegals($illegals = '')
> {
> $this->illegals = $illegals;
> }
>
506c513
< preg_match_all("/{([^ \t\r\n}]+)}/", $this->getVar($handle),
$m);
---
> preg_match_all("/{([^ \t\r\n}$this->illegals]+)}/", $this-
>getVar($handle), $m);
538c545
< $str = preg_replace('/{[^ \t\r\n}]+}/', '', $str);
---
> $str = preg_replace("/{[^ \t\r\n}$this->illegals]+}/",
'', $str);
542c549
< $str = preg_replace('/{([^ \t\r\n}]+)}/',
---
> $str = preg_replace("/{([^ \t\r\n}$this->illegals]+)}/",
In the two examples above, $t->setIllegals(',') would work.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=15993&edit=1