diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index ac186ad48..f5b552dca 100755 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -110,7 +110,6 @@ yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$? if [ "$EXIT_CODE" != 0 ]; then cat ERROR bashio::log.yellow "... config file has an invalid yaml format. Please check the file in $CONFIGSOURCE. Errors list above." - exit 1 fi # Export all yaml entries as env variables @@ -160,6 +159,8 @@ while IFS= read -r line; do # extract keys and values KEYS="${line%%=*}" VALUE="${line#*=}" + # Sanitize " ' ` in current variable + VALUE="${VALUE//[\"\'\`]/}" # export to python if command -v "python3" &>/dev/null; then [ ! -f /env.py ] && echo "import os" > /env.py @@ -167,9 +168,9 @@ while IFS= read -r line; do python3 /env.py fi # set .env - if [ -f /.env ]; then echo "$KEYS=$VALUE" >> /.env; fi + if [ -f /.env ]; then echo "$KEYS=\"$VALUE\"" >> /.env; fi mkdir -p /etc - echo "$KEYS=$VALUE" >> /etc/environment + echo "$KEYS=\"$VALUE\"" >> /etc/environment # Export to scripts if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export $KEYS=\"$VALUE\"" /etc/services.d/*/*run* 2>/dev/null; fi if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $KEYS=\"$VALUE\"" /etc/cont-init.d/*run* 2>/dev/null; fi @@ -177,7 +178,7 @@ while IFS= read -r line; do if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi echo "export ${KEYS}=\"${VALUE}\"" >> ~/.bashrc # Show in log - if ! bashio::config.false "verbose"; then bashio::log.blue "$KEYS='$VALUE'"; fi + if ! bashio::config.false "verbose"; then bashio::log.blue "$KEYS=\"$VALUE\""; fi else bashio::log.red "$line does not follow the correct structure. Please check your yaml file." fi