默认情况下,codeigniter url中是否支持100%非英语字符? [英] Are non-english characters 100% supported in codeigniter urls by default?

查看:106
本文介绍了默认情况下,codeigniter url中是否支持100%非英语字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确定CodeIgniter是否100%支持此行为.

让我怀疑的是,在config.phppermitted_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆