默认情况下,codeigniter url中是否支持100%非英语字符? [英] Are non-english characters 100% supported in codeigniter urls by default?
问题描述
我想确定CodeIgniter是否100%支持此行为.
让我怀疑的是,在config.php
中permitted_uri_chars
如下:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
它说只允许使用英语字符.但是请考虑以下网址的结果:
-
http://localhost/codeigniter/index.php/controller/method/hell0-there+++
结果:The URI you submitted has disallowed characters.
-
http://localhost/codeigniter/index.php/controller/method/hello-سلام
结果:没问题!!!
模式'a-z 0-9~%.:_\-'
不能接受单词سلام
(在波斯语中,表示你好"),但不会像前面的示例那样出错!
为什么会发生这种行为?
现在下一个问题:是否需要在模式中添加和包含波斯字符?
我正在考虑将config.php
更改为这样:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
// Add all the persian characters after standard pattern:
$config['permitted_uri_chars'] .= 'آابپتثجچحخدذرزسشصضطظعغفقکگلمنوهیي۱۲۳۴۵۶۷۸۹۰';
非ASCII字符应进行URLEncoded转换,将其转换为%F3
等.我相信基于%
和a-z 0-9
允许使用该字符>
I want to be sure if this behavior is 100% supported in CodeIgniter.
What doubts me is that in config.php
the permitted_uri_chars
is as followed:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
It says that only English chars are allowed. BUT consider the results of following urls:
http://localhost/codeigniter/index.php/controller/method/hell0-there+++
Result: The URI you submitted has disallowed characters.
http://localhost/codeigniter/index.php/controller/method/hello-سلام
Result: No problem!!!
The word سلام
(which is in Persian and means "hello") cannot be accepted by the pattern 'a-z 0-9~%.:_\-'
, but it doesn't error like the previous example!
Why does this behavior happen?
Now the next question: Is there any NEED to add and include Persian characters in the pattern?
I was thinking of changing the config.php
to be like this:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
// Add all the persian characters after standard pattern:
$config['permitted_uri_chars'] .= 'آابپتثجچحخدذرزسشصضطظعغفقکگلمنوهیي۱۲۳۴۵۶۷۸۹۰';
Non-ASCII character should be URLEncoded converting them to %F3
etc. Which I believe would be allowed based on the %
and a-z 0-9
这篇关于默认情况下,codeigniter url中是否支持100%非英语字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!