phpphalconphalcon-routing

Phalcon Micro "handle()" method decodes URI


My Phalcon Micro application receives URI parts with encoded slashes (%2F).

For example, before calling $app->handle():

echo $app->request->getURI(); // -> /resources/res%2F01/all

But it looks like the $app->handle() method is decoding my URI, converting my %2F to a slash. Thus, the following routing rule...

$app->get('/resources/{code:[^\/]+}/all', function() { /* ... */ });

... will not work properly since %2F is now a slash. Controller-side, the %2F is no longer present.

echo $code // -> res/01

Is there a way to tell Phalcon to not decode URIs?


EDIT

In the end, Phalcon is not decoding the URI, but is based on the $_GET['_url'] parameter for its routing, and the %2F code is already missing there.


Solution

  • Your url is not accepted by route regexp. You disallow slashes in route definition - [^\/]+.

    If you want to route match this url, route definition must looks like:

    $app->get('/resources/{code:.+}/all', function() { /* ... */ });
    

    Is there a way to tell Phalcon to not decode URIs?

    I think no.