ZF-7944: Change urlencode to rawurlencode
Description
I have route, for example, "/preview/:name", which at first call (/preview/my image.jpg) generates preview and save it at location /preview/my image.jpg, so the next call will not be handled by PHP but statically outputed by Apache. The problem is that uri "/preview/my image.jpg" after encoding becomes "/preview/my+image.jpg", which is correctly handled by PHP, but can not be recognized by Apache. This problem is fixed in rawurlencode(), why not to use it in Zend_Controller_Router_Route?
Comments
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-09-24T17:18:12.000+0000
Where exactly would you be suffering from this? When creating a url by using the url-viewhelper? If so; you can set an escape parameter to false, I assume that would solve your problem.
Posted by Mark van der Velden (dynom) on 2009-10-28T04:11:43.000+0000
The major difference between rawurlencode() and urlencode is that rawurlencode() has more respect to encoding when it comes to the space character. The rawurlencode() function encodes this to "%20" where urlencode() doesn't (it encodes to a "+"). This can be a problem since "+" is a special character and it doesn't decode properly across all URI schemes (although if you stay within a PHP application, this doesn't pose a problem).
RFC 3986 states that the following characters are reserved: ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," and that they need to be escaped, so using a "+" to "encode" a space is actually incorrect.
Using rawurlencode() over urlencode() also offers greater compatibility, a proof of concept: http://codepad.org/XiLAeHvI
Since both functions are used within ZF I vote to replace all use of urlencode() to rawurlencode() in all instances, and their decoding counterfeit.
RFC3986 - http://tools.ietf.org/html/rfc3986 RFC2396 - http://tools.ietf.org/html/rfc2396
Posted by A.J. Brown (ajbrown) on 2010-09-27T12:44:25.000+0000
this is currently a problem for me. I have a route defined as follows:
resources.router.routes.vehicleguide.type = "Zend_Controller_Router_Route" resources.router.routes.vehicleguide.route = "used auto parts/make/:make/:model" resources.router.routes.vehicleguide.defaults.controller = guide resources.router.routes.vehicleguide.defaults.action = vehicle resources.router.routes.vehicleguide.defaults.make = null resources.router.routes.vehicleguide.defaults.model = null
URLS like this resolve correctly: /used+auto+parts/make/volkswagen/jetta-gli
URLS like this (encoded spaces) do not: /used%2Bauto%2Bparts/make/volkswagen/jetta-gli
Posted by Adam Lundrigan (adamlundrigan) on 2011-11-17T03:05:07.000+0000
Is this something which can be fixed in ZFv1 without breaking existing apps? If so I can help move it forward.