0

I'm using the Segment router as a child of one of my main Literal routes in a ZF2 (currently using 2.3.5) application. The router needs to be able to handle Turkish input characters coming in from the URL. My first attempt looked something like this (as a child route):

'book' => array(
    'type' => 'Zend\Mvc\Router\Http\Segment',
    'options' => array(
        'route' => 'kitap/:book[/]',
        'constraints' => array(
            'book' => '[a-zA-ZçÇşŞğĞıİöÖüÜ1-3.+ ]+',
        ),
    ),
),

This mostly worked for everything I needed it to: upper and lower-case letters, numbers up to 3, etc. Then I noticed it wasn't accepting Turkish capital dotted i's (İ) so I started checking. It actually isn't accepting any Turkish characters at all even though the rest of the bits seem to be processed properly.

Even using \w+ does not seem to match (locale not set to Turkish?), but using \S+ does so the router doesn't have a problem with Turkish URLs, it's just the matching that's whacked.

I looked through the source code for the Segment router and it appears to be using preg_match(), which should handle this just fine. What am I missing here?

Edit: This question is about the same problem, but in the Regex router. This even more closely related one deals with the same issue in the Segment router and is nearly a duplicate, but it does not solve my problem as the code demonstrated is against an old version of ZF2 and is neither a drop in match, nor was I able to port it to work against the updated upstream module which appears to handle things a bit differently. I've also filed an upstream bug report hoping this gets fixed there, but I'm still left without a currently working module. I am happy to create a replacement module for my project with this function patched but am not able to figure out the changes to make it work.

Community
  • 1
  • 1
Caleb
  • 5,084
  • 1
  • 46
  • 65
  • Any reason for not using the u modifier? http://php.net/manual/en/reference.pcre.pattern.modifiers.php – sg- Mar 17 '15 at 11:24
  • @StevenGeorge I know about the `u` modifier, but how do I use it in this context? Without modifying the `vendor/*` code (which is installed on the server, not part of my project), my code is not responsible for setting PCRE modifiers. What is the proper way to do this inside a site based on ZF2? – Caleb Mar 17 '15 at 11:27
  • Take a look at this: http://stackoverflow.com/questions/15658354/how-to-set-a-utf8-modifier-for-regex-of-a-regex-route-in-zend-framework-2 – sg- Mar 17 '15 at 11:30
  • @sq Thanks. That's useful, but see my edit as that does not quite get me to a solution. – Caleb Mar 17 '15 at 13:12

0 Answers0