helper for urldecode and encode, some fixes

This commit is contained in:
Jaromil 2015-09-23 15:42:05 +02:00
parent c66c7b3be3
commit fca82a9e74
1 changed files with 81 additions and 4 deletions

85
zuper
View File

@ -47,7 +47,7 @@ function _msg() {
done
local command="print -P"
local progname="$fg[magenta]${TOMBEXEC##*/}$reset_color"
local progname="$fg[magenta]${PROGRAM##*/}$reset_color"
local message="$fg_bold[normal]$fg_no_bold[normal]$msg$reset_color"
local -i returncode
@ -266,7 +266,7 @@ destruens+=(_ztmp_destructor)
# saves everything in global array tok=()
arrs+=(tok)
strtok() {
fn "strtok $*"
fun="strtok $*"
_string="$1"
_delim="$2"
req=(_string _delim)
@ -546,7 +546,7 @@ EOF
function helper.html-strip xml_strip html_strip() { sed 's/<[^>]\+>//g' }
# changes stdin string special chars to be shown in html
function helper.excape-html escape_html() {
function helper.escape-html escape_html() {
sed -e '
s/\&/\&amp;/g
s/>/\&gt;/g
@ -555,8 +555,85 @@ s/"/\&quot;/g
'
}
}
# escapes special chars in urls
function helper.decode-url decode_url urldecode() {
sed -e '
s/%25/%/gi
s/%20/ /gi
s/%09/ /gi
s/%21/!/gi
s/%22/"/gi
s/%23/#/gi
s/%24/\$/gi
s/%26/\&/gi
s/%27/'\''/gi
s/%28/(/gi
s/%29/)/gi
s/%2a/\*/gi
s/%2b/+/gi
s/%2c/,/gi
s/%2d/-/gi
s/%2e/\./gi
s/%2f/\//gi
s/%3a/:/gi
s/%3b/;/gi
s/%3d/=/gi
s/%3e//gi
s/%3f/?/gi
s/%40/@/gi
s/%5b/\[/gi
s/%5c/\\/gi
s/%5d/\]/gi
s/%5e/\^/gi
s/%5f/_/gi
s/%60/`/gi
s/%7b/{/gi
s/%7c/|/gi
s/%7d/}/gi
s/%7e/~/gi
s/%09/ /gi
'
}
function helper.encode-url encode_url urlencode() {
sed -e '
s/%/%25/g
s/ /%20/g
s/ /%09/g
s/!/%21/g
s/"/%22/g
s/#/%23/g
s/\$/%24/g
s/\&/%26/g
s/'\''/%27/g
s/(/%28/g
s/)/%29/g
s/\*/%2a/g
s/+/%2b/g
s/,/%2c/g
s/-/%2d/g
s/\./%2e/g
s/\//%2f/g
s/:/%3a/g
s/;/%3b/g
s//%3e/g
s/?/%3f/g
s/@/%40/g
s/\[/%5b/g
s/\\/%5c/g
s/\]/%5d/g
s/\^/%5e/g
s/_/%5f/g
s/`/%60/g
s/{/%7b/g
s/|/%7c/g
s/}/%7d/g
s/~/%7e/g
s/ /%09/g
'
}
}
# }}} Helpers
# {{{ Config