Welcome Guest, Not a member yet? Register   Sign In
permitted uri chars problem
#1

[eluser]hugle[/eluser]
Hello everyone!
I think I have some problems with regexp..

if I used to have:
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
in config file, the symbol "-" (minus) was accepted.

But when I changed to this, to accept russian characters, I get Dissalowed chars error.

Code:
$config['permitted_uri_chars'] = 'АБВГҐДЕЄЁЖЗИІЫЇЙКЛМНОПРСТУФХЦЧШЩЮЯЬЪабвгґдеєёжзиіыїйклмнопрстуфхцчшщюяьъ a-z 0-9~%.:_-';
What/where is the problem with that?
Russian characters get accepted, but not the "-" ...

What I am doing wrong?

Big thanks!
Jaroslav
#2

[eluser]pistolPete[/eluser]
Just tested it here, it's working,
Which text encoding do you use to save the config.php file?
#3

[eluser]hugle[/eluser]
[quote author="pistolPete" date="1234528668"]Just tested it here, it's working,
Which text encoding do you use to save the config.php file?[/quote]

Strange, I get disallowed error.

The file is saved as UTF-8. Could it be an error ?
#4

[eluser]pistolPete[/eluser]
No, UTF-8 is fine.
Which CI Version are you using?
Which routes did you setup?
#5

[eluser]hugle[/eluser]
[quote author="pistolPete" date="1234543349"]No, UTF-8 is fine.
Which CI Version are you using?
Which routes did you setup?[/quote]

CI version is 1.7

the routes I have which connects to this controller are:
Code:
$route['statji'] = "main/index";
$route['statji/view/:num'] = "statji/view";
$route['statji/view/:num/:any'] = "statji/view";

But I think that the problem is somehow connected with regexpSad

because if I change permitted_uri_chars = '' ; - everything works just fine Sad
#6

[eluser]pistolPete[/eluser]
What uri_protocol are you using?
Code:
$config['uri_protocol'] = ?
#7

[eluser]hugle[/eluser]
it is set to:
Code:
$config['uri_protocol']    = "AUTO";
#8

[eluser]pistolPete[/eluser]
Maybe there is a bug in CI, let's find out.

Create a file named MY_URI.php and save it with the following contents in ./system/application/libraries/:
Code:
<?php
class MY_URI extends CI_URI {
  
    function MY_URI()
    {
        parent::CI_URI();
    }
            
    function _fetch_uri_string()
    {
        parent::_fetch_uri_string();
        echo 'settings:';
        echo '<br />permitted_uri_chars: '.$this->config->item('permitted_uri_chars');
        echo '<br />uri_protocol: '.$this->config->item('uri_protocol');
        echo '<br />uri_string: '.$this->uri_string;
        echo '<br /> output of $_SERVER:<br/><pre>';
        print_r($_SERVER);
        echo '</pre>';
        die();
    }
}

/* End of file MY_URI.php */
/* Location: ./system/application/libraries/MY_URI.php */

This class "extends" the core class CI_URI and exits after _fetch_uri_string().
In the output you will see, which request information the webserver provides, such as REQUEST_URI, QUERY_STRING and PATH_INFO. These values also depend on your .htaccess file!
Depending on your uri_protocol CI fetches the uri_string.

If I lookup http://domain.com/ööö, the output looks like the attached screenshot.
(I attached a screenshot because the forum converts urlencoded strings )

My .htaccess file contains:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

After removing the file MY_URI.php again, I changed uri_protocol to different values (while still trying to lookup http://domain.com/ööö) , these are the results with the following standard setting:
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
AUTO: "The URI you submitted has disallowed characters."
PATH_INFO: "The URI you submitted has disallowed characters."
REQUEST_URI: "404 Page Not Found"

So the last one passed, but because there was no controller / route a 404 error appeared.
If you look again at the attached screenshot, you see that the REQUEST_URI contains the urlencoded string which only consists of permitted characters.

Please try to reproduce the same steps as above and post your results here.
#9

[eluser]sl3dg3hamm3r[/eluser]
I reproduced your steps. Same results, BUT: REQUEST_URI seems to accept the encoded string, but the page can't be found afterwards (controller and method exists and do work fine with AUTO).

Here the trace:
#10

[eluser]pistolPete[/eluser]
I found out that in function _validate_request($segments) in Router.php there is no conversion of urlencoded strings:

Code:
// I added whitespaces between urlencoded strings so it doesn't get converted by the forum
[ ... ]
// if we try to access domain.com/ööö
// using uri_protocol = REQUEST_URI
// then $segments[0] is "% C 3 % B 6 % C 3 % B 6 % C 3 % B 6"

// So CI tries to find a controller named "% C 3 % B 6 % C 3 % B 6 % C 3 % B 6.php" which doesn't exist!
if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
[ ... ]




Theme © iAndrew 2016 - Forum software by © MyBB