From 4737b5b950ef88d6753086dab5fc5cab16fcdf1a Mon Sep 17 00:00:00 2001 From: Yury Kossakovsky Date: Sun, 11 May 2025 16:29:19 -0600 Subject: [PATCH] Enhance unquoting logic in secrets generation script - Updated the unquoting mechanism in 03_generate_secrets.sh to repeatedly remove surrounding quotes from variable values, improving the handling of quoted strings and ensuring accurate environment variable assignment. --- scripts/03_generate_secrets.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/03_generate_secrets.sh b/scripts/03_generate_secrets.sh index d1bb9f7..24c61c9 100755 --- a/scripts/03_generate_secrets.sh +++ b/scripts/03_generate_secrets.sh @@ -54,10 +54,20 @@ if [ -f "$OUTPUT_FILE" ]; then if [[ -n "$line" && ! "$line" =~ ^\\s*# && "$line" == *"="* ]]; then varName=$(echo "$line" | cut -d'=' -f1 | xargs) varValue=$(echo "$line" | cut -d'=' -f2-) - # Simple unquote for "value" or 'value' - if [[ "$varValue" =~ ^\\"(.*)\\"$ || "$varValue" =~ ^\\'(.*)\\'$ ]]; then - varValue="${BASH_REMATCH[1]}" - fi + # Repeatedly unquote "value" or 'value' to get the bare value + _tempVal="$varValue" + while true; do + if [[ "$_tempVal" =~ ^\"(.*)\"$ ]]; then # Check double quotes + _tempVal="${BASH_REMATCH[1]}" + continue + fi + if [[ "$_tempVal" =~ ^\'(.*)\'$ ]]; then # Check single quotes + _tempVal="${BASH_REMATCH[1]}" + continue + fi + break # No more surrounding quotes of these types + done + varValue="$_tempVal" existing_env_vars["$varName"]="$varValue" fi done < "$OUTPUT_FILE"