How can I make the Segment router sanely process c

2019-09-11 00:47发布

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.

0条回答
登录 后发表回答