diff --git a/lib/lib_sanitizer.sh b/lib/lib_sanitizer.sh index 116d01e..e07a127 100644 --- a/lib/lib_sanitizer.sh +++ b/lib/lib_sanitizer.sh @@ -35,22 +35,23 @@ arg_check() { sanitize_arg() { declare input="$1" # Define allowed characters: - # letters, digits, dot, underscore, slash, equals, [, ], colon, double-quote, hyphen, space. - declare allowed='a-zA-Z0-9._/=\[\]:"\- ' + # letters, digits, dot, underscore, slash, equals, [, ], colon, double-quote, hyphen, plus, space. + declare allowed declare disallowed - disallowed=$(printf '%s' "${input}" | tr -d "${allowed}") + allowed='a-zA-Z0-9._/=[]:"-+ ' + disallowed=$(printf '%s' "$input" | sed "s/[$allowed]//g") if [[ -n ${disallowed} ]]; then { printf "❌ Invalid character : '%s'. \n" "${disallowed//?/& }" printf "❌ in argument : '%s'. \n" "${input}" - printf "❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - ' \n" + printf "❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' \n" printf "\n" } >> "${LOG_ERROR}" boot_screen_cleaner printf "\e[91m❌ Invalid character : '%s'. \e[0m\n" "${disallowed//?/& }" >&2 printf "\e[91m❌ in argument : '%s'. \e[0m\n" "${input}" >&2 - printf "\e[91m❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - ' \e[0m\n" >&2 + printf "\e[91m❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' \e[0m\n" >&2 # shellcheck disable=SC2162 read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m' exit "${ERR_INVLD_CHAR}"