Welcome Guest, Not a member yet? Register   Sign In
underscores in arguments from url
#1

[eluser]burfield[/eluser]
I'm struggling with why CI is putting underscores in place of spaces that are passed in through the url.

For instance, the url looks like this:

domain.com/f/g/en/us/my+sample

OR

domain.com/f/g/en/us/my sample

The controller looks like this:

function g($a,$b,$c) {
echo $a.'<BR>';
echo $b.'<BR>';
echo $c.'<BR>';
}

Will output:

en
us
my_sample


I found this thread: http://ellislab.com/forums/viewthread/94091

And attempted changed the values of $config['uri_protocol'] however, nothing helps.

REQUEST_URI fails with 404 errors.

AUTO gives me the underscore problem.

urlencode(), urldecode()...nothing helps.

Can someone point me in the right direction?

Thanks.

-- Jason
#2

[eluser]slowgary[/eluser]
I think it has something to do with permitted URI chars, which may be a config variable. I think it's a nice feature, as long as you expect it.

You can write a function like this:
Code:
function apples_bananas()
{
}
And call it many ways:
Code:
http://www.domain.com/controller/apples+bananas
http://www.domain.com/controller/apples.bananas
http://www.domain.com/controller/apples-bananas
http://www.domain.com/controller/apples bananas
#3

[eluser]burfield[/eluser]
Thanks, but that is a bit different than the problem I am having.

The problem here is that the *arguments* to the function are having underscores added to them.

If the argument is 'slow query' (or 'slow query' or 'slow+query') CI replaces it with: slow_query

It is not related to permitted characters, if so it would give an error for that. It is not giving any error, just replacing the characters.

It also replaces periods with an underscore as well, so 'slow.query' becomes 'slow_query'

I'm sure there is some reason for this, but it does not seem to be documented anywhere that I can find and seems to be a bit of a bug. I have found that one other thread mentioning a similar problem, but the solution was more of a work-around than anything else.

Still love to hear any input from anyone.

Thanks.

-- Jason

[quote author="slowgary" date="1248328741"]I think it has something to do with permitted URI chars, which may be a config variable. I think it's a nice feature, as long as you expect it.

You can write a function like this:
Code:
function apples_bananas()
{
}
And call it many ways:
Code:
http://www.domain.com/controller/apples+bananas
http://www.domain.com/controller/apples.bananas
http://www.domain.com/controller/apples-bananas
http://www.domain.com/controller/apples bananas
[/quote]
#4

[eluser]sophistry[/eluser]
http://ellislab.com/forums/viewreply/578089/
#5

[eluser]burfield[/eluser]
[quote author="sophistry" date="1248332101"]http://ellislab.com/forums/viewreply/578089/[/quote]

Already did that. No help.

Actually tried all of them. AUTO, REQUEST_URI, etc, etc.

This is all somehow tied in to using a .htaccess file to not show the index.php page. The only way I have found to get the params to work as expected is to not use the .htaccess file and have index.php in the url. Not what I want though.

Any other suggestions?

Thanks.

-- Jason
#6

[eluser]sophistry[/eluser]
curious about the .htaccess - maybe you are running CGI vs. php_mod based on whether you invoke the htaccess? what about the re-write rules, anything in there?

so when you dump the $_SERVER global var, do you see any URI strings that would be suitable? that's all those config variables do anyway, the code picks the URI string by heuristic if you don't force it.

cheers.
#7

[eluser]wiredesignz[/eluser]
This thread may help.
http://ellislab.com/forums/viewthread/68163/

@sophistry: Did you notice I put the cute url tags on my link which makes it perfect for clicking. Tongue
#8

[eluser]sophistry[/eluser]
[quote author="wiredesignz" date="1248340475"]
@sophistry: Did you notice I put the cute url tags on my link which makes it perfect for clicking. Tongue[/quote]

ha ha! yes, i'm aware of those url tags. Wink but, sometimes i feel like tweaking posters if it seems like they didn't do their homework. besides, any decent browser should be able to identify that as an url and convert it.

anyhow, thanks for the reminder about how i can continue to better the CI forums! i wish everyone were as assiduous as you and I.
#9

[eluser]burfield[/eluser]
Thanks...I took a look at that and it may work, however, I'm not real excited about needing to modify the CI code to make something like this function properly. It seems that defeats part of the reason for using a framework to begin with, no?

It it has to be done, then I suppose that will need to happen, but would prefer to not need to do that.

My .htaccess file is pretty straightforward:

RewriteEngine On
RewriteBase /ci/

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Thanks.

@sophistry ... are you accusing me of not doing my 'homework' ? Kinda rude, no? Statements like that are what prevent some people from participating and learning. Afraid of remarks such as yours. Lucky for me, I'm not.

-- Jason


[quote author="wiredesignz" date="1248340475"]This thread may help.
http://ellislab.com/forums/viewthread/68163/

@sophistry: Did you notice I put the cute url tags on my link which makes it perfect for clicking. Tongue[/quote]
#10

[eluser]sophistry[/eluser]
[quote author="burfield" date="1248375564"]@sophistry ... are you accusing me of not doing my 'homework' ? Kinda rude, no?[/quote]

@burfield, please, take a breath, relax, we're all in this together. Confusedmiley: i agree, my pithy post was not perfectly pellucid. however, this issue is well-covered in the forums. besides, i wasn't "accusing" you, merely hoisting petards. Wink

my first post was really just to let you know that this was not a CI issue - the underscores are there because of a legacy issue with PHP; that piece of information seemed to be missing from your summation so i figured you hadn't [strike]done your homework[/strike] seen that post.

ok, so which URI string in the $_SERVER global would be suitable? it sounds like you found one, but you didn't mention which one. yes, do not modify CI core code. that is bad juju.

so, the htaccess looks ok. i see you have the ? after index.php - what ISP is it? some require that, some don't.

cheers. glad my fractious fomenting didn't leave you metagrobolized or worse, fuguing.




Theme © iAndrew 2016 - Forum software by © MyBB