After updating my CakePHP version from 2.2.2 to 2.6.2, one of my routes stopped working properly.
Router::connect('/articles/:keywords', array('action' => 'search', 'controller' => 'Articles', 'keywords' => null), array('pass' => array('keywords'), 'keywords' => '[A-Za-z0-9\+_]+'));
It takes input such as "World" and "World+News" through a url such as website.com/articles/World+News and passes whatever is after articles/ to the search function in the Articles controller. This was working fine up until the update. Now it will pass up the route and go to my "cannot find route" route if there is anything other than alphanumeric characters. It's like the regex isn't matching properly. e.g. "World" and "World123" will work but "World+News" will not.
Things I have tried:
I've been scouring everywhere, trying all sorts of regex combinations (the ones I have match successfully in the tester), and just generally trying to find out why this route will match but I cannot. This was working fine before the update and I can't find anything in the CakePHP documentation that would suggest why this isn't working. As far as I know the expressions have been right and I have confirmed that they fully match using a regex tester. Any help would be appreciated, thanks!
Actually the problem is the regex, at least it's part of the problem.
In earlier versions, CakePHP passed the raw URL into the matching subject, which however was rather problematic, as it could require very ugly regexes, especially for non-ASCII characters. Now the URL decoded variant is being passed:
https://github.com/cakephp/.../commit/d5283af818b59c5d96355d6e42bbd77e1322d8cb
So since +
has a special meaning in URL encoding and actually stands for a whitespace, your regex won't match anymore. It's rather easy to fix, just match a whitespace instead of the +
.