How should data be encoded in the URL |
Hi,
I need to put JSON data in my URLs, but when I encode it with urlencode() or rawurlencode() CI complains that "The URI you submitted has disallowed characters." My current workaround is to first encode using rawurlencode() and then encode the result with base_64encode()... is there a better way to do this? Code: base64_encode(rawurlencode($json_data));
You can just enable the relevant characters ...
An alternative is this SO answer, which shows how simple it is to make URL-safe Base64 encoding (it's probably not fully compliant with the actual spec, but is completely safe to use regardless): http://stackoverflow.com/a/5835352/468027 Also, you don't need to urlencode if you're going to apply Base64 after that.
Thanks, I wasn't sure about enabling additional characters because of the intimidating warning in the config file ;- ) I do not fully understand the repercussions it can have on security, so I'll probably stick with the base64 encoding if there is no other way built in CI.
There's a closed (but yet still ongoing) issue on github about the URL-decoding that's currently done by default, so it might end up not requiring you to make an extra effort, but we'll see how that works out ...
Damn forum software ... the following link got double posted for some reason, then both posts disappeared after I deleted only one of them and now doesn't let me post it again until I modify it ... </rant>
https://github.com/bcit-ci/CodeIgniter/c...17c882bbef
free online tool for php urlencode function.. kindly take a look on this..
http://onlinew3tools.com/url-encode
Free Online Developer Tools | Online W3 Tools
(01-06-2017, 02:58 AM)vivekanandhan Wrote: free online tool for php urlencode function.. kindly take a look on this.. Did you really have to bump two year-old threads just to advertise this? It's not like this is a super-hard to do or google thing. |
Welcome Guest, Not a member yet? Register Sign In |