Bug in URI ?!

Andy Wardley abw at wardley.org
Mon Aug 21 08:45:16 BST 2006


Dominic Mitchell wrote:
> At the time this thread started, I was unaware that TT could do that.

TT also attempts to "Do The Right Thing" when you use the URL plugin.

   [% USE URL('/example') %]
   [% URL(a=10,b=20) %]       # /example?a=10&b=20

Strictly speaking this is incorrect. It *should* use bare ampersands
to create a URL...

   /example?a=10&b=20         # URL

...and then leave it up to the user to ensure that the URL is correctly
encoded for whatever medium in use (i.e. HTML)

   /example?a=10&b=20     # HTML encoded URL

But instead the URL plugin does the more useful thing and automatically
encodes the ampersands for you.  The plugin used to be "correct" until
we applied a patch (hi Leon!) which made it "useful".  Some people (hi
Randal!) complained that "useful" wasn't as good as "correct".  In
the end, they're both right.

Cut a long story short, I solved the problem by wrapping up a $JOINT.
 From the Changes file 2006-02-02:

* Added the $JOINT package variable to Template::Plugin::URL to
   provide a work-around for the URL plugin which incorrectly (as
   we now know) encodes '&' as '&'

   http://rt.cpan.org/Ticket/Display.html?id=11551
   http://tt2.org/pipermail/templates/2005-December/008158.html

It's a sub-sexy solution but it does the job for now.

There's a number of things slated for TT3 to address the deeper
issues.  We're putting hooks into the stash to allow you to install
filters for all data going in or coming out.  There's also going
to be some kind of multi-channel output view layer thingy which
you'll be able to configure to Do The Right Thing when it comes to
output filtering, formatting and encoding.

A



More information about the london.pm mailing list