Subject: | HTML.escape() double-escapes already-escaped entities |
Date: | Mon, 29 Dec 2014 13:59:21 -0500 |
To: | bug-Template-Toolkit [...] rt.cpan.org |
From: | Michael Stemle <themanchicken [...] gmail.com> |
If you use the code:
[% HTML.escape( ">tag<" ) %]
then it will expand to:
&gt;tag&lt;
which is different from the expected behavior of leaving existing escaped
entities alone.
I recommend changing the regexp for ampersand to be this instead:
s/&(?![a-zA-Z0-9#-]+;)/&/g
This uses a negative look-ahead assertion to only match entities which are
not already encoded.
Please let me know if you have any questions.
--
~ Michael D. Stemle, Jr.