From 0214ae153740ec3db97acbb3059d76c369294b6e Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Sun, 12 Jul 2026 16:26:21 +0200 Subject: [PATCH] fix(docker): escape env values in env.js heredoc SEC-9: a double quote or backslash in APP_* broke the generated JS (silent config corruption). js_escape() escapes both and collapses newlines before interpolation. Docker-verified with a hostile APP_BRAND_NAME: env.js parses, value round-trips exactly. --- docker/entrypoint.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 3e493769..e3cf2372 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -7,12 +7,23 @@ set -e ENV_JS="/usr/share/nginx/html/env.js" +# Escapes a value for safe embedding in a double-quoted JS string literal +# (backslashes, double quotes; newlines collapsed to spaces). +js_escape() { + printf '%s' "$1" | tr '\n' ' ' | sed 's/\\/\\\\/g; s/"/\\"/g' +} + +SITE_NAME=$(js_escape "${APP_SITE_NAME:-Faunosteo}") +BRAND_NAME=$(js_escape "${APP_BRAND_NAME:-Faunosteo}") +FOOTER_NAME=$(js_escape "${APP_FOOTER_NAME:-Faunosteo}") +TAGLINE=$(js_escape "${APP_TAGLINE:-Outils pour ostéopathes animaliers}") + cat > "$ENV_JS" <