Created bug ticket http://routes.groovie.org/trac/routes/ticket/67 .
The only workaround I can think of is to recognize "C " in the action
and replace it with "C++". Not elegant bit it will get you by until
Routes is fixed. I hope you don't have lots of incoming IDs with
pluses and spaces in them.
--
Mike Orr <slugg...@gmail.com>
I should note that the latest routes-dev repo does have the multiple
decoding bug fixed. It also fixes the routes resource issue with
using ; instead of / at the end for actions. It will probably be
released soon, in the next week or so.
Cheers,
Ben
If your ID can include a slash, you should be using a wildcard variable:
m.connect("/:topic/view/*id", controller="foo", action="bar")
You can try ":controller/:action/*id", but no guarantees on what wrong
URLs it may swallow.
As for whether Paste should defer unescaping, here's what the RFCs say:
ftp://ftp.isi.edu/in-notes/rfc2616.txt (HTTP, section 3.2.3)
http://www.faqs.org/rfcs/rfc2396.html (URI, sections 2,2, 2,3,
2,4, 2,4,1, 2.4.2)
The slash is a reserved character, meaning it's distinct from its
escaped equivalent (%2F). As opposed to tilde which is unreserved, so
"~" and "%7E" are completely equivalent.
However, I'm sure Paste would find it very tedious to unescape some
characters but not others. There's also the issue of filenames with
spaces. When should "a%20space.jpg" be unescaped to "a space.jpg"?
--
Mike Orr <slugg...@gmail.com>
The WSGI spec refers to the CGI spec, which indicates that PATH_INFO
should be url-unquoted. Unfortunately as a result there's no way to
distinguish %2f from /. I would recommend translating this character to
something else.
Ian
> The WSGI spec refers to the CGI spec, which indicates that PATH_INFO
> should be url-unquoted. Unfortunately as a result there's no way to
> distinguish %2f from /. I would recommend translating this
> character to
> something else.
Alternatively, you can put the variable in as a query argument, where
Routes will ignore it.
Cheers,
Ben
Unlike Rails though, Pylons functions underneath WSGI, which is a
subset of CGI and specifically says that the URL Pylons see will have
already been URL decoded, thus Routes has no idea what slash was
originally URL encoded. I should note that the Rails solution there
breaks depending on if the connector used to hook up the Rails app URL
decodes the URL first. This is part of why the WSGI spec operates as a
subset of the CGI spec, to ensure portability and consistency.
To have Routes use one percent encoded URL in some cases, but not in
others, will cause a similar bout of confusion. As sometimes the app
will work as people expect (depending on their deployment), and
sometimes it will break.
Why not put the data you want to retain the slashes, into the query
string? You'll get the characters you want then, though Routes will be
unable to directly dispatch on them, you could write a conditional
function for the Routes match, that looks at the query string:
http://routes.groovie.org/manual.html#conditions
That way you could pull out the data you wanted from the
environ['QUERY_STRING'] (or pass environ to a WSGIRequest obj to make
it easier to use), then add the variable to the Routes match dict so
your actions can see them.
Cheers,
Ben
But doesn't the wildcard variable type exist precisely for this case?
map.connect("images/*id", controller="main", action="image")
matches:
images/ABC.jpg
images/123/456
images/nature/winter/ABC.jpg
--
Mike Orr <slugg...@gmail.com>
Should "split" as:
["Laptops", "HP/Compaq", "Armada-XXX"]
["Printers", "Brother", "D/PCL-344"]
As far as I see, the "best" way to deal with these is to escape / as $2F
to get around the CGI-induced WSGI limitation.