Subject: | Characters not escaped properly in Template::Plugin::URL |
Date: | Wed, 20 Nov 2013 14:17:36 +0100 |
To: | bug-Template-Toolkit [...] rt.cpan.org |
From: | František Svoboda <frantisek [...] netsafe.cz> |
The URL plugin doesn't escape utf-8 characters properly for use in URL
causing an error when trying to decode them later.
How to reproduce:
- in template, use URL module: [% USE url %]
- in same template, employ this code to generate a link: <a href="[%
url('test', var='???') %]">test</a>
- click on the link generated by above code
- on perl 5.14.4 built for i686-linux (Linux dev 3.2.0-4-686-pae #1 SMP
Debian 3.2.41-2+deb7u2 i686 GNU/Linux) this causes:
Generic Exception: utf8 "\x91" does not map to Unicode at
/opt/perl-5.14.4/lib/5.14.4/i686-linux/Encode.pm line 215.
The characters in var are not correctly escaped for use in URl. Using
utf8 (use utf8) does not help.
How to fix:
- use URI::Escape in the URL.pm module;
- alter escape() function so:
sub escape {
my $toencode = shift;
return uri_escape_utf8($toencode);
}