diff --git a/profile.sh b/profile.sh index aa4d76d..f305490 100644 --- a/profile.sh +++ b/profile.sh @@ -113,6 +113,15 @@ parse_conf() value="${value#"${value%%[![:space:]]*}"}" value="${value%$'\r'}" + # Protect against command injection by disallowing certain characters in keys + value="${value//\`/}" + value="${value//\$\(/}" + + # Correctly interpretet internal variables (e.g. $HOME) + if [[ "$value" == *\$* ]]; then + value=$(envsubst <<< "$value") + fi + # Strip quotes (handling both " and ') value="${value%\"}"; value="${value#\"}" value="${value%\'}"; value="${value#\'}" @@ -122,7 +131,8 @@ parse_conf() current_array["$key"]="$value" fi done < "$config_file" -}# ------------------------------------------------------------------------------ +} +# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------