OK, I pounded my head a few minutes on this one, but I found it.
The URI plugin correctly handles the uri-escaping of parameters, but
what if you have a weird filename (say from the Directory plugin) that
contains single-quotes and spaces? How do you escape it, because the
URI plugin *correctly* leaves the part to the left of the query-mark
alone?
Simple:
[% USE url;
MACRO uri_escape(thing)
GET url('', escaped = thing).replace('.*?escaped=','');
-%]
[%
USE dir = Directory('.');
FOREACH file = dir.list; -%]
Here's a clean link: <a href="[% uri_escape(file.name) | html %]">
[% END; -%]
And that's your trick for the day.
Remember... to go from files to uris, uri-escape them. To include
that escaped item in HTML, you need to html-escape THAT. (And that
may be wrong in the current URL plugin... I think it's missing
an html pass on the base uri.)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!