Welcome Guest, Not a member yet? Register   Sign In
Why Chinese character is not allowed in the url, and how to pass the validation?
#1

[eluser]maomaode[/eluser]
I don't know why CI disable the Chinese character in the url, i found there's code in the core of CI checking the invalid characters, but seems it's very popular to have non-English characters in the url. is it not safe to do so? Any other work around? I don't want to change the code of CI, it's hard to maintain, It'll be perfect if there's a global config


Thanks in advance!
#2

[eluser]hepp[/eluser]
You can set allowed characters in config.php -> $config['permitted_uri_chars']
#3

[eluser]maomaode[/eluser]
Thanks for the reply,

But It's not possible to list all the Chinese characters(at least 6000) in the filter array.

I think the best way is change the library/Router.php, around line 408, just urlencode($str) before preg_match(...)

But as i said, i prefer not to change the CI's core lib.


Can I say, it can be a improvement here, if yes, i'll file an issue.
#4

[eluser]esra[/eluser]
[quote author="maomaode" date="1190120618"]Thanks for the reply,

But It's not possible to list all the Chinese characters(at least 6000) in the filter array.

I think the best way is change the library/Router.php, around line 408, just urlencode($str) before preg_match(...)

But as i said, i prefer not to change the CI's core lib.


Can I say, it can be a improvement here, if yes, i'll file an issue.[/quote]

You might want to add a new thread to the Features Request forum to ensure that your idea is considered in the next major release.

To solve the problems for now, create a libraries/ directory under application/ if one does not already exist. Then create an extended MY_Router.php file in application/libraries/ and subclass system/ibraries/Router.php library (class MY_Router extends CI_Router{}). Add the original method from Router.php to the MY_Router.php file and modify the method to suit your needs. CI will automatically load MY_Router.php rather than Router.php. All other methods in Router.php will be inhierited by MY_Router.php. There is no need to manually load MY_Router.php or autoload it. CI knows what to do when a MY_filename.php file exists.

CI was actually designed to make it easy to extend the framework to suit a developers needs based on the notion that no single framework can meet everyone's needs. Instructions for doing so are covered in the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB