CodeIgniter Forums
Roundtrip disallowed characters error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Roundtrip disallowed characters error (/showthread.php?tid=10315)



Roundtrip disallowed characters error - El Forum - 07-26-2008

[eluser]freshface[/eluser]
When I have this error

Quote:The URI you submitted has disallowed characters.

I want to load an other view, but how do i fetch this in my controller?


Roundtrip disallowed characters error - El Forum - 07-26-2008

[eluser]Yash[/eluser]
Question is not clear to me..Give more detail


Roundtrip disallowed characters error - El Forum - 07-26-2008

[eluser]freshface[/eluser]
When somebody enters disallowed characters in the url i want to capture the error instead of showing the default CI error.
Edit, extending the permitted characters is not an option.


Roundtrip disallowed characters error - El Forum - 07-26-2008

[eluser]Yash[/eluser]
http://ellislab.com/forums/viewreply/410947/

You can achieve a much neater “upgrade” to this error message without hacking the core files.

Simply make a file in your application’s “libraries” directory called MY_URI.php, and fill it with:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_URI extends CI_URI {

    function _filter_uri($str)
    {
        if ($str != '' AND $this->config->item('permitted_uri_chars') != '')
        {
            if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
            {
                show_404($str);
                exit();
            }
        }
            
        return $str;
    }
    
}

?>

i.e. a direct copy of the appropriate function from the core class, but with your new addition of show_404() too.


Roundtrip disallowed characters error - El Forum - 07-26-2008

[eluser]freshface[/eluser]
Thx, works like a charm!


Roundtrip disallowed characters error - El Forum - 07-26-2008

[eluser]Yash[/eluser]
your welcome