404 error if multibyte URL's are allowed.
Closed this issue · 8 comments
When I added
URLSegmentFilter:
default_allow_multibyte: true
to .yml file, I got 404 error if visiting multibyte URL, like this - for example: www.mydomain.com/ru/заглавная-страница
Please check that the URL works with Translatable enabled, but without the LanguagePrefix module...
Discussion here: http://www.silverstripe.org/community/forums/general-questions/show/101333?start=8
Could you send me a MySQL dump of your test database? That would give me the russian content, which I can't create myself. Also your default Translatable locale?
My default Translatable locale is en_US. MySQL dump you can download here: http://error.si/data/sql_dump.zip
Thanks, got it :)
At a quick poke through I'd say this double escape is probably causing issues: https://github.com/Martimiz/silverstripe-languageprefix/blob/master/code/PrefixModelAsController.php#L74 - although the default charset is utf8 which should be fine, so I am not sure. But seems most likely since latin charsets likely won't be touched (since they're generally all lowercase numbers, letters, and hyphens anyway) which accounts for the majority of test cases (especially if transliterating).
The original ModelAsController uses sprintf to build a raw WHERE clause to pass directly in, rather than using the ORM, so needs the manual escape.
Alas I do not have a development environment on hand to debug this through.
The advantage of DataObject::get_one is that it caches - which is generally of little use here anyway unless someone makes the same search (for some bizarre reason) later on in their controller (for which they'd presumably already have the class instantiated for, having landed on the page they're looking for). So I don't think that needs changing. Hopefully just changing to $filter = array('URLSegment' => $URLSegment)
should do the trick.