fix(hooks): replace unsafe eval with declare in check-config.sh

The load_env_vars function used eval to assign .env values, which
executes command substitutions in backtick-containing comments.
Replace eval with declare and strip inline comments before assignment.

Fixes #361
This commit is contained in:
Dave Morin
2026-05-08 00:59:09 -07:00
committed by Trevin Chow
parent aba6172032
commit a6bd481e61
+4 -1
View File
@@ -33,8 +33,11 @@ load_env_vars() {
[[ -z "$key" ]] && continue
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs | sed 's/^["'\''"]//;s/["'\''"]$//')
# Strip inline comments (# preceded by whitespace) to prevent
# command substitution in backtick-containing comments
value="${value%%[[:space:]]#*}"
if [[ -n "$key" && -n "$value" ]]; then
eval "ENV_${key}=\"${value}\""
declare "ENV_${key}=${value}"
fi
done < "$file"
fi