modxcms / Redirector

Handles all your site redirects in MODx Revolution.
https://docs.modx.com/current/en/extras/redirector/index
8 stars 21 forks source link

Problems with cyrillic URLs #48

Closed whitebyte closed 9 years ago

whitebyte commented 9 years ago

Currently Redirector doesn't handle cyrillic URLs nicely. When trying to process cyrillic URL it spits something like this

Error parsing condition with key 0: ('%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8/' REGEXP `modRedirect`.`pattern` OR '%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8/' REGEXP CONCAT('^', `modRedirect`.`pattern`, '$'))

into the log, and always redirect using the first rule in the redirect list.

I think the reason is that cyrillic URLs are "rawurlencoded", and instead of nice url, say, "новости/", Redirector plugin recieves something like this: "%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8/".

The quick fix is to replace line 15 in the Redirector plugin, instead of

$search = $_SERVER['REQUEST_URI'];

it should be

$search = rawurldecode($_SERVER['REQUEST_URI']);

I don't see any immediate side effects, didn't tested it carefully though, so no PR for now.