Skip to main content.
home | support | download

Back to List Archive

Re: [swish-e] swish.cgi: Escaping special characters in $link_href

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Thu May 14 2009 - 16:51:18 GMT
On Thu, May 14, 2009 at 06:36:08PM +0200, u7l11ey@mail.lrz-muenchen.de wrote:
> 
> In the meantime, I found a solution using the URI::Escape module (
> http://search.cpan.org/~gaas/URI-1.37/URI/Escape.pm ) which does exactly
> what I need.

You are correct.  The advice I gave for the "html" filter in the
template was incorrect.  That simply escapes to the normal HTML entities.



Template toolkit has the "url" filter which escapes:

Without the url filter it passed through directly:

$ echo ' <a href="[% "http://weather.com/El Niņo" %]">El Niņo</a>' | tpage
 <a href="http://weather.com/El Niņo">El Niņo</a>



With the "url" filter:

$ echo ' <a href="[% "http://weather.com/El Niņo" | url %]">El Niņo</a>' | tpage
 <a href="http://weather.com/El%20Ni%C3%83%C2%B1o">El Niņo</a>


Don't get it confused with the "uri" filter which you would use for,
say, a query parameter not an entire url.

$ echo ' <a href="[% "http://weather.com/El Niņo" | uri %]">El Niņo</a>' | tpage
 <a href="http%3A%2F%2Fweather.com%2FEl%20Ni%C3%83%C2%B1o">El Niņo</a>

-- 
Bill Moseley.
moseley@hank.org
Sent from my iMutt
_______________________________________________
Users mailing list
Users@lists.swish-e.org
http://lists.swish-e.org/listinfo/users
Received on Thu May 14 12:51:16 2009