From 18789d9ea60bf2a7791612bb7563029188d3e39c Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 26 Apr 2023 13:47:27 -0400 Subject: [PATCH] escape backslashes when inserting variables from env with perl for frontend w/ burnettk --- spiffworkflow-frontend/bin/boot_server_in_docker | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-frontend/bin/boot_server_in_docker b/spiffworkflow-frontend/bin/boot_server_in_docker index 9cb99865..c34bfda3 100755 --- a/spiffworkflow-frontend/bin/boot_server_in_docker +++ b/spiffworkflow-frontend/bin/boot_server_in_docker @@ -34,8 +34,9 @@ if [[ -n "$react_configs" ]]; then exit 1 fi + escaped_react_config=$(sed -E 's|/|\\/|g' <<<"${react_config_without_prefix}") # actually do the search and replace to add the js config to the html page - perl -pi -e "s/(window.spiffworkflowFrontendJsenv=\{\})/\1;window.spiffworkflowFrontendJsenv.${react_config_without_prefix}/" "$index_html_file" + perl -pi -e "s/(window.spiffworkflowFrontendJsenv=\{\})/\1;window.spiffworkflowFrontendJsenv.${escaped_react_config}/" "$index_html_file" if ! grep -Eq "${react_config_without_prefix}" "$index_html_file"; then >&2 echo "ERROR: Could not find '${react_config_without_prefix}' in '${index_html_file}' after search and replace. It is likely that the assumptions in boot_server_in_docker about the contents of the html page have changed. Fix the glitch in boot_server_in_docker."