Code igniter is restrictive over permitted url characters (a good thing!), and it’s simple enough to edit the permitted_uri_config option to add more charaters. However, what if you’re dealing with Japanese charaters in the url?
Well (after a little searching) it turns out that this isn’t too difficult to fix as the config value is a regex and one can add the kanji charater ranges in a similar fashion to the standard ascii ‘a-z’ syntax:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
↓
$config['permitted_uri_chars'] = '一-龠ぁ-んァ-ヴーa-zA-Z0-9a-z 0-9~%.:_-';
courtesy of: http://pricewave.blog110.fc2.com/blog-category-4.html
autoreverse says
Hi Chris
Here’s the other solution (hack) I promised (I should learn to scroll below the fold)
In Router.php change
if ( ! preg_match(“|^[“.preg_quote($this->config->item(‘permitted_uri_chars’)).”] $|i”, $str))
to
if ( ! preg_match(“|^[“.preg_quote($this->config->item(‘permitted_uri_chars’)).”] $|i”, rawurlencode($str)))
A link to the bug report: http://www.codeigniter.com/bug_tracker/bug/2929/
Derek Allard says the CI guys are working on a better solution but you might want to add yours too so they are aware of what other people are doing.
yongfook says
dude, I freaking looked everywhere for this regex expression for one of my old projects. my google skills are the fail. thanks for posting the solution!