Allowing only question marks in input |
[eluser]ModernNinjaX[/eluser]
Hey guys, I'm new to Codeigniter but I'm loving it so far... here's a question I have though I have a controller method that needs to accept an external API key, which could possibly have a question mark in it. How would I allow *only* this character in URLs? Codeigniter gives it a 404 immediately, even when I don't use the default routing (index.php/controller/method/api?key) Thanks in advance EDIT: By 'only' I mean that this is the only special character I want to allow (if CI is even designed to handle question marks)
[eluser]tonanbarbarian[/eluser]
im sure you have a reason for passing an API key via GET, i.e. in a URL, however I would consider that a little bit insecure I would recommend looking at other ways to handle this if possible. submission via POST and then storing in the session would be one way
[eluser]CroNiX[/eluser]
Have a look at /config/config.php $config['permitted_uri_chars']
[eluser]ModernNinjaX[/eluser]
[quote author="tonanbarbarian" date="1287561264"]im sure you have a reason for passing an API key via GET, i.e. in a URL, however I would consider that a little bit insecure I would recommend looking at other ways to handle this if possible. submission via POST and then storing in the session would be one way[/quote]Unfortunately I don't have a choice. I send the user to the external login site, they sign in, then the site sends back and API key in a querystring (I have the API send it to a non-CI file, which then redirects it to a CI-formatted file, defeating the purpose). @CroNiX - Thanks, can't believe I missed this. I'll try it out ![]()
[eluser]ModernNinjaX[/eluser]
I just tried changing permitted_uri_chars and it did nothing to fix the 404 that I am getting. Example (where test1=controller, test2=method) index.php/test1/test2/test3?test ...will return a 404. Any suggestions?
[eluser]Watermark Studios[/eluser]
Although I'm not an expert in mod_rewrite, you could always include a rewrite rule to handle the URL, break it up and return it as index.php/test1/test2/test3/test4 which would have a method of test2 accepting 2 parameters of test3 and test4.
[eluser]ModernNinjaX[/eluser]
[quote author="Watermark Studios" date="1287622962"]Although I'm not an expert in mod_rewrite, you could always include a rewrite rule to handle the URL, break it up and return it as index.php/test1/test2/test3/test4 which would have a method of test2 accepting 2 parameters of test3 and test4.[/quote]Apologies if I didn't state this clearly, but that's not what I'm trying to do. The API is designed to return something like this: index.php?apikey=[key] index.php is a NON-CI script that will redirect to index.php/controller/method/[key] [key] COULD be a question mark. It isn't designed to initiate a new GET query, though. It's still part of apikey. Anyway, this isn't exactly my problem. I think I know how to properly handle the returns. The issue is that index.php/controller/method/[key] will immediately 404 by codeigniter if apikey has a question mark in it.
[eluser]ModernNinjaX[/eluser]
Anyone have any answers? Here's a better overview of the problem. 1. User goes to external login page 2. On success, that page goes back to a NON-CI page, with an apikey in the querystring. 3. That page simply redirects to a CI page with the correct format (index.php/controller/method/apikey) However... if apikey has a question mark in it (still part of apikey, *NOT* a new definition in a querystring) in it, Codeigniter returns 404. I could just use str_replace() in the pages that handle the apikey, but that would be a last resort option. Really hoping someone can point me in the right direction, thanks. |
Welcome Guest, Not a member yet? Register Sign In |