diff --git a/lib/http_tools.sh b/lib/http_tools.sh index c537517..92fc74e 100755 --- a/lib/http_tools.sh +++ b/lib/http_tools.sh @@ -491,8 +491,8 @@ get_header_value () { } ####################################################################### -# This function percent-encodes all characters except the "Unreserved -# Characters" defined in section 2.3 of RFC 3986. +# This function percent-encodes all characters in its string argument +# except the "Unreserved Characters" defined in section 2.3 of RFC 3986. # # See: https://gist.github.com/cdown/1163649 # https://en.wikipedia.org/wiki/Percent-encoding @@ -523,7 +523,9 @@ percent_encode () { } ####################################################################### -# This function percent-decodes all percent-encoded characters. +# This function is the inverse of the percent_encode function, that +# is, it percent-decodes all percent-encoded characters in its string +# argument. ####################################################################### percent_decode () { # percent_decode @@ -534,15 +536,7 @@ percent_decode () { return 2 fi - local encoded_string - - # the percent_encode function doesn't convert spaces to - # plus signs (+) but the input string to the percent_decode - # function may have been encoded in some other manner so we - # first decode plus signs (+) into spaces - encoded_string="${1//+/ }" - - printf '%b' "${encoded_string//%/\\x}" + printf '%b' "${1//%/\\x}" } # DEPRECATED: Use percent_encode and percent_decode instead.