From 45d2bfbcf8c2a7c821fcfdf167af090cb9b0d9ba Mon Sep 17 00:00:00 2001 From: NW Date: Wed, 24 Jun 2026 12:09:32 +0100 Subject: [PATCH] fix: newline validation bug in entrypoint.sh echo adds trailing newline, causing false positives. Use printf and case statement instead. --- tor-proxy/entrypoint.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tor-proxy/entrypoint.sh b/tor-proxy/entrypoint.sh index f21afb4..8497ec3 100644 --- a/tor-proxy/entrypoint.sh +++ b/tor-proxy/entrypoint.sh @@ -4,14 +4,13 @@ set -e validate_alnum() { local val="$1" local name="$2" - if ! echo "$val" | grep -qE '^[a-zA-Z0-9._-]+$'; then + case "$val" in + *$'\n'*) echo "ERROR: $name contains newlines"; exit 1 ;; + esac + if ! printf '%s' "$val" | grep -qE '^[a-zA-Z0-9._-]+$'; then echo "ERROR: $name contains invalid characters: $val" exit 1 fi - if echo "$val" | grep -q $'\n'; then - echo "ERROR: $name contains newlines: $val" - exit 1 - fi } validate_alnum "$SSH_HOST_IP" "SSH_HOST_IP"