From 7e2c0bc96f941328dfd3b04c5c4ec2efc3657ace Mon Sep 17 00:00:00 2001 From: Ben Chidgey Date: Thu, 23 Sep 2021 16:05:39 +0100 Subject: [PATCH] FIX: Stop sed escaping numbers 2 and 7 in Docker An interesting edge case has come up whilst using BackStage. When using the example frontend-with-nginx work to run a separate frontend, whilst then providing an override for the googleAnalyticsTrackingId in yaml config via APP_CONFIG_app_googleAnalyticsTrackingId. I received an "Octal escape sequences are not allowed in strict mode" error in the browser dev console. After looking into it it appears that the sed used escapes the numbers 2 and 7 if they are present in an APP_CONFIG_* ENV override value. I happened to have both a 2 and a 7 in my GA ids, hence the edge case part! Of note this did not happen on my mac but it is present inside of the nginx:mainline Docker container used in the example. This fix simply removes the hex from the sed substitution regex and replaces it with a single quote ' Signed-off-by: Ben Chidgey --- contrib/docker/frontend-with-nginx/docker/inject-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/docker/frontend-with-nginx/docker/inject-config.sh b/contrib/docker/frontend-with-nginx/docker/inject-config.sh index a0cea96ff3..98797b65d3 100755 --- a/contrib/docker/frontend-with-nginx/docker/inject-config.sh +++ b/contrib/docker/frontend-with-nginx/docker/inject-config.sh @@ -23,7 +23,7 @@ function inject_config() { # escape ' and " twice, for both sed and json local config_escaped_1 - config_escaped_1="$(echo "$config" | jq -cM . | sed -e 's/[\\"\x27]/\\&/g')" # \x27 = ' + config_escaped_1="$(echo "$config" | jq -cM . | sed -e 's/[\\"'\'']/\\&/g')" # escape / and & for sed local config_escaped_2 config_escaped_2="$(echo "$config_escaped_1" | sed -e 's/[\/&]/\\&/g')"