mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-10 04:26:17 +02:00
Fix shit done on omz_urlencode rework by someone
Bad usage of zparseopts
This commit is contained in:
parent
6376140a7c
commit
279d67d702
1 changed files with 16 additions and 13 deletions
|
|
@ -120,12 +120,15 @@ zmodload zsh/langinfo
|
||||||
# -P causes spaces to be encoded as '%20' instead of '+'
|
# -P causes spaces to be encoded as '%20' instead of '+'
|
||||||
function omz_urlencode() {
|
function omz_urlencode() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
zparseopts -D -E -a opts r m P
|
local -a opt_path opt_reserved opt_mark
|
||||||
|
zparseopts -D -E r=opt_reserved m=opt_mark P=opt_path
|
||||||
|
|
||||||
local in_str=$1
|
local in_str=$1
|
||||||
local url_str=""
|
local url_str=""
|
||||||
local spaces_as_plus
|
local spaces_as_plus=1
|
||||||
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
|
if [[ ! -z $opt_path ]]; then
|
||||||
|
spaces_as_plus=
|
||||||
|
fi
|
||||||
local str="$in_str"
|
local str="$in_str"
|
||||||
|
|
||||||
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
|
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
|
||||||
|
|
@ -146,11 +149,11 @@ function omz_urlencode() {
|
||||||
local reserved=';/?:@&=+$,'
|
local reserved=';/?:@&=+$,'
|
||||||
local mark='_.!~*''()-'
|
local mark='_.!~*''()-'
|
||||||
local dont_escape="[A-Za-z0-9"
|
local dont_escape="[A-Za-z0-9"
|
||||||
if [[ -z $opts[(r)-r] ]]; then
|
if [[ ! -z $opt_reserved ]]; then
|
||||||
dont_escape+=$reserved
|
dont_escape+=$reserved
|
||||||
fi
|
fi
|
||||||
# $mark must be last because of the "-"
|
# $mark must be last because of the "-"
|
||||||
if [[ -z $opts[(r)-m] ]]; then
|
if [[ ! -z $opt_mark ]]; then
|
||||||
dont_escape+=$mark
|
dont_escape+=$mark
|
||||||
fi
|
fi
|
||||||
dont_escape+="]"
|
dont_escape+="]"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue