From cfd3c2b18bdae63d49d3fe78a1db64eda0a118c4 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 7 Oct 2021 10:57:31 -0700 Subject: [PATCH] simplify character whitelist using built-in shell expansions --- sh/oxo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/oxo b/sh/oxo index 6f6b291..b14f624 100755 --- a/sh/oxo +++ b/sh/oxo @@ -65,7 +65,7 @@ oxo() { ### @- local g="$f" # restrict the filepath to simple ascii characters that curl likes. - if [ -n "$(printf '%s' "$f" | tr -d \''0-9A-Za-z !#$%&()*+,./;=@[]^_`{}~-')" ]; then + if [ "$f" != "${f#*[! -~]}" ] || [ "$f" != "${f#*[\":<>?\\|]}" ]; then # copy the user's file to a temporary path and use that instead. g=/tmp/oxo #printf "$warn" "oxo: special characters found: $f" >&2