Welcome Guest, Not a member yet? Register   Sign In
spaces in URLs converted to _
#1

[eluser]AtlantixMedia[/eluser]
Hello all,

I noticed that CI automatically converts spaces in URLs to _. that is, in an url like this:

www.domain.com/main/search/big+city

by echoing the 3rd segment or function parameter from within the Search function, I see that it has been converted to big_city. how do I avoid this?

thanks in advance
#2

[eluser]Ryuuzaki92[/eluser]
urlencode()? it converts spaces to and other non-alpha chars to its ascii code
#3

[eluser]AtlantixMedia[/eluser]
maybe I didn't make myself clear. this is something that CI does automatically. it converts already urlencoded urls containing spaces (+) to _
#4

[eluser]AtlantixMedia[/eluser]
any idea? anyone?
#5

[eluser]barbazul[/eluser]
let me tell you that I've done some testing activating and deactivating xss and I haven't come across any scenario where spaces get replaced.

what version of CI are you running?

could you post some code as to illustrate what you're doing?
#6

[eluser]AtlantixMedia[/eluser]
I'm running ver 1.5.4

http://www.domain.com/main/search/big+city

where main is a controller, search is a function, and big+city is a parameter. from within the Search function, I echo the parameter passed by the url and instead of printing big city, it prints big_city. I tried with and without urldecode. same result

Code:
<?php

class Main extends Controller {


    function Main()
    {
        parent::Controller();
    }

    function Search($query)
    {
       echo $query;
    }

}
?>
#7

[eluser]barbazul[/eluser]
I don't have acces to a web server right now but you should consider upgrading to CI 1.6.1

The tests I've done on 1.6.1 earlier were identical to yours and the spaced weren't replaced
#8

[eluser]AtlantixMedia[/eluser]
ok...I finally upgraded to 1.6.2. Still, I'm experiencing the same issue. spaces are replaced with an _

how can I fix this?

thanks
#9

[eluser]AtlantixMedia[/eluser]
any idea? anyone? is it possible php.ini has to do with it?
#10

[eluser]mglinski[/eluser]
not an issue, a feature.
If you want spaces add a space in the allowed characters config option in the main config file.
-Matt




Theme © iAndrew 2016 - Forum software by © MyBB