From 506bd03a38030a622dcd8572bfc7ca7f7f315a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 28 Jun 2023 09:21:54 +0200 Subject: [PATCH] Merged detached head into master --- functions.sh | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/functions.sh b/functions.sh index 9997cc0..92a6533 100755 --- a/functions.sh +++ b/functions.sh @@ -1169,26 +1169,10 @@ EOF } -urlencode() { - # urlencode - - local LANG=C - local length="${#1}" - for (( i = 0; i < length; i++ )); do - local c="${1:i:1}" - case $c in - [a-zA-Z0-9.~_-]) printf "$c" ;; - *) printf '%%%02X' "'$c" ;; - esac - done -} - -urldecode() { - # urldecode - - local url_encoded="${1//+/ }" - printf '%b' "${url_encoded//%/\\x}" -} +urlencode() { python3 -c "import sys; from urllib.parse import quote; print(quote(sys.argv[1]));" "$@"; } +urldecode() { python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.argv[1]));" "$@"; } +urlencodeplus() { python3 -c "import sys; from urllib.parse import quote_plus; print(quote_plus(sys.argv[1]));" "$@"; } +urldecodeplus() { python3 -c "import sys; from urllib.parse import unquote_plus; print(unquote_plus(sys.argv[1]));" "$@"; } findlocallogins() { last -F -a $(for i in $(find /var/log -maxdepth 1 -name "wtmp*"|sort -h);do echo -n "-f $i ";done)|grep -v "pts/\|reboot\|wtmp"|awk '{print $4,$5,$7}'|uniq