Alexander Kriegisch
2008-02-03 17:19:03 UTC
We all know that httpd can URL-decode strings, but there is no
counterpart to do the opposite, i.e. URL-encode strings, in BusyBox. Do
you think it would be useful to have such a little tool, maybe even as
an optional (non-standard) httpd feature?
I know that URL encoding can be done via sed, e.g. like so (taken from
the tool "Callmonitor" by Andreas B?hmann):
urlencode() {
_urlencode '%\1' "$@"
}
_urlencode() {
local replacement=$1; shift
local txt=$*
case $txt in
*[!0-9A-Z_a-z!*.-]*) ;;
*) echo -n "$txt"; return ;;
esac
echo -e $(echo -n "$txt" |
hexdump -v -e '/1 "!%02x"' |
sed '
s/!\(2[1ade]\|3[0-9]\|4[1-9a-f]\|5[0-9af]\|6[1-9a-f]\|7[0-9a]\)/\\x\1/g
s/!\([[:xdigit:]]\{2\}\)/'"$replacement"'/g
')
}
Denis, what do you think? Is there any chance of getting a C-coded
little binary doing URL-encoding? BB's wget does not do it either,
unfortunately.
counterpart to do the opposite, i.e. URL-encode strings, in BusyBox. Do
you think it would be useful to have such a little tool, maybe even as
an optional (non-standard) httpd feature?
I know that URL encoding can be done via sed, e.g. like so (taken from
the tool "Callmonitor" by Andreas B?hmann):
urlencode() {
_urlencode '%\1' "$@"
}
_urlencode() {
local replacement=$1; shift
local txt=$*
case $txt in
*[!0-9A-Z_a-z!*.-]*) ;;
*) echo -n "$txt"; return ;;
esac
echo -e $(echo -n "$txt" |
hexdump -v -e '/1 "!%02x"' |
sed '
s/!\(2[1ade]\|3[0-9]\|4[1-9a-f]\|5[0-9af]\|6[1-9a-f]\|7[0-9a]\)/\\x\1/g
s/!\([[:xdigit:]]\{2\}\)/'"$replacement"'/g
')
}
Denis, what do you think? Is there any chance of getting a C-coded
little binary doing URL-encoding? BB's wget does not do it either,
unfortunately.
--
Alexander Kriegisch
Alexander Kriegisch