1

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.

kagmole
  • 2,005
  • 2
  • 12
  • 27

1 Answers1

1

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.

maximkou
  • 5,252
  • 1
  • 20
  • 41
  • Nice. I thought the `.+` regex would also take the `/all` part, looks like it isn't. As for Phalcon, after looking at the sources, it looks like it is not decoding the URI but is based on $_GET['_url'] and the %2F is already missing there. – kagmole Jun 02 '17 at 11:08