ZF-7944: Change urlencode to rawurlencode


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?


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.

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:

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 - RFC2396 -

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

Is this something which can be fixed in ZFv1 without breaking existing apps? If so I can help move it forward.