Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
1
Task/URL-decoding/UNIX-Shell/url-decoding-1.sh
Normal file
1
Task/URL-decoding/UNIX-Shell/url-decoding-1.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
urldecode() { local u="${1//+/ }"; printf '%b' "${u//%/\\x}"; }
|
||||
5
Task/URL-decoding/UNIX-Shell/url-decoding-2.sh
Normal file
5
Task/URL-decoding/UNIX-Shell/url-decoding-2.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
urldecode http%3A%2F%2Ffoo%20bar%2F
|
||||
http://foo bar/
|
||||
|
||||
urldecode google.com/search?q=%60Abdu%27l-Bah%C3%A1
|
||||
google.com/search?q=`Abdu'l-Bahároot@
|
||||
64
Task/URL-decoding/UNIX-Shell/url-decoding-3.sh
Normal file
64
Task/URL-decoding/UNIX-Shell/url-decoding-3.sh
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
function urldecode
|
||||
{
|
||||
typeset encoded=$1 decoded= rest= c= c1= c2=
|
||||
typeset rest2= bug='rest2=${rest}'
|
||||
|
||||
if [[ -z ${BASH_VERSION:-} ]]; then
|
||||
typeset -i16 hex=0; typeset -i8 oct=0
|
||||
|
||||
# bug /usr/bin/sh HP-UX 11.00
|
||||
typeset _encoded='xyz%26xyz'
|
||||
rest="${_encoded#?}"
|
||||
c="${_encoded%%${rest}}"
|
||||
if (( ${#c} != 1 )); then
|
||||
typeset qm='????????????????????????????????????????????????????????????????????????'
|
||||
typeset bug='(( ${#rest} > 0 )) && typeset -L${#rest} rest2="${qm}" || rest2=${rest}'
|
||||
fi
|
||||
fi
|
||||
|
||||
rest="${encoded#?}"
|
||||
eval ${bug}
|
||||
c="${encoded%%${rest2}}"
|
||||
encoded="${rest}"
|
||||
|
||||
while [[ -n ${c} ]]; do
|
||||
if [[ ${c} = '%' ]]; then
|
||||
rest="${encoded#?}"
|
||||
eval ${bug}
|
||||
c1="${encoded%%${rest2}}"
|
||||
encoded="${rest}"
|
||||
|
||||
rest="${encoded#?}"
|
||||
eval ${bug}
|
||||
c2="${encoded%%${rest2}}"
|
||||
encoded="${rest}"
|
||||
|
||||
if [[ -z ${c1} || -z ${c2} ]]; then
|
||||
c="%${c1}${c2}"
|
||||
echo "WARNING: invalid % encoding: ${c}" >&2
|
||||
elif [[ -n ${BASH_VERSION:-} ]]; then
|
||||
c="\\x${c1}${c2}"
|
||||
c=$(\echo -e "${c}")
|
||||
else
|
||||
hex="16#${c1}${c2}"; oct=hex
|
||||
c="\\0${oct#8\#}"
|
||||
c=$(print -- "${c}")
|
||||
fi
|
||||
elif [[ ${c} = '+' ]]; then
|
||||
c=' '
|
||||
fi
|
||||
|
||||
decoded="${decoded}${c}"
|
||||
|
||||
rest="${encoded#?}"
|
||||
eval ${bug}
|
||||
c="${encoded%%${rest2}}"
|
||||
encoded="${rest}"
|
||||
done
|
||||
|
||||
if [[ -n ${BASH_VERSION:-} ]]; then
|
||||
\echo -E "${decoded}"
|
||||
else
|
||||
print -r -- "${decoded}"
|
||||
fi
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue