Cphalcon: Phalcon route exception when uri contains persian letter 'م'

Created on 12 Mar 2017  ·  11Comments  ·  Source: phalcon/cphalcon

Hello,
Phalcon throws a route exception when there is persian letter 'م' (meem) in uri parameters. There's no problem when other unicode and persian letters used. The exception value is null.

For example this route works:
http://127.0.0.1/testRouter/index/index/یسلرسی

but this throws error:
http://127.0.0.1/testRouter/index/index/م

Here is more information about the letter 'م' (meem):
https://unicode-table.com/en/0645/

Unicode number: U+0645
HTML-code: م
Block: Arabic

  • Phalcon version: 3.0.4
  • PHP Version: 7.0.13
  • Operating System: Windows 10
  • Server: Apache
bug low

All 11 comments

I also encountered this problem before, this is not phalon's bug, this problem is in apache mod_rewite.
When I use xampp with php 5.5 or bellow there is no problem. xampp php 5.6 and above have this problem.

@yasharrashedi You're right, I tested with nginx and there wasn't any issue. But I don't think it's a problem with apache alone because other apps with laravel or wordpress work fine with the same configuration.

Unicode chars in URL can be tricky. It also depends how the browser interprets those.
By simple fact that you don't have issue with nginx, I would say this is not a Phalcon's bug.
Your source code also needs to be saved as UTF-8 (.php file) in order for this unicode routes to work. I've seen this issue when developers working on Windows save it as Windows-125x charset, and when they upload it on staging Linux server their routes does not work.

@stamster Thanks for reply, the unicode string is not in the source code, it's in the url parameters.
I don't use unicode routes, it's for search queries specifically.

I tested this problem with a plain php file and a simple .htaccess file on wampserver 3.0.6
Windows 10
PHP Version 5.6.25

.htaccess contents
RewriteEngine On RewriteRule ^test1/(.*)$ index.php?params=$1 [L] RewriteRule ^test2/([0-9A-Za-z\x7f-\xff]*)$ index.php?params=$1 [L]
index.php content
php <?php print_r($_GET);
http://localhost/mod_rewrite/test1/سلام
outputs:
Array ( [params] => سلا� )
http://localhost/mod_rewrite/test2/سلام
outputs:
Array ( [params] => سلام )
http://localhost/mod_rewrite/test1/ABCabc123سلام
outputs:
Array ( [params] => ABCabc123سلا� )
http://localhost/mod_rewrite/test2/ABCabc123سلام
outputs:
Array ( [params] => ABCabc123سلام )
When using
http://localhost/mod_rewrite/test1/ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی
I get 404 error

but
When using
http://localhost/mod_rewrite/test2/ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی
outputs:
Array ( [params] => ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی )

So I think the problem is in using (.*) in .htaccess when using persian or arabic characters

@yasharrashedi Good catch. Could you please send pull request to the phalcon/docs?

@sergeyklay let me test all possibilities and exceptions then send pull request to prevent future problems. I need a few days

@yasharrashedi I think It is not mandatory to search for all possible all possibilities and exceptions. At least enough of one case to give users the idea

ok I'll do it soon

try to use ([\s\S]*) instead of (.*) and it will work like charm but i still have problem on some sub version of php 5.6 but in most cases this Regex replacement work.

This issue was moved to phalcon/docs#1413

Was this page helpful?
0 / 5 - 0 ratings