There’s a route in my application that contains a user’s email address, which can contain a plus sign. An example url is /manage/test+email@email.com. However when the URL is parsed and decoded, the plus sign gets converted to a space so I’m unable to locate the correct user based on email in the action.
I’ve found that I can fix the problem by overriding CHttpRequest’s decodePathInfo function to call
rawurldecode
instead of
urldecode
on line 264. I’d rather not modify this function though, since it’s called on every page load, and after changing it to use rawurldecode, uploading images with spaces in the file name no longer works.
Has anyone else experienced this or knows of a way to fix it? Thanks in advance.
Thanks for the help–using createUrl lead me to the problem. Apache was redirecting URLs without trailing slashes to one with a trailing slash, so
/manage/test%2Bemail%40email.com
was redirected to
/manage/test+email@email.com/
Somewhere in the redirection process, the %2B was converted to a plus sign, which was then converted to a space when Yii decoded the URL. Ensuring the the URL starts with a trailing slash fixed the issue.