UrlEncoding-Safe Delimiter
So, the site I'm working on has a filter system that works by passing a system of keys and values through a request.
The whole site is about to go to re-factor and I am maintaining an existing site, so before discussing the RIGHT way to implement this, I just need ideas for changing my separator.
The current format is as follows:
cf=<key>:<value>
The problem is that I recently ran into a problem because some of our new values for this filter contain :
them. Ie:cf=MO_AspectRatio:16:10
Value is UrlEncoded, but browsers de-encode% 3a to: on the fly, because: is not inherently breaking URLs.
I need suggestions for the correct separators, which are not :
, -
, _
, &
, ?
, that makes sense. I am not looking for a solution like ()
or something wild.
a source to share
This Wikipedia article is useful to learn more about unconditional and reserved characters.
While the tilde ~ is probably the best option. But there is still a chance that sooner or later it will break. Or you have to properly document and validate it on user login.
a source to share
the general syntax of a URI scheme allows two valid parameter separators: &
and ;
. I have always seen the first, and never later. The symbol is ?
required to correctly identify the start of the query string, so I would not recommend using it. The same applies to those /
used in URLs.
Any character that is not one of these and is not part of your meanings is acceptable. Here's a list of the possible ones, sorted by my own preference, not including the ones you explicitly rejected:
,
+
|
#
$
!
Any of them should do.
Also, even if you specifically asked not to: In future refactorings, try to use real URI parameters (using &). Will save a lot of head heads.
a source to share
The most straight forward solution is to base64 encode the entire string and then base64 decode it on the input.
Another option is to urlencode it twice before exiting and then urldecode it once on the input (there will be auto urldecode done on all php inputs or maybe apache is not sure who does this).
a source to share