From f41ab733721b317166704ba020dae8b67b3ed58a Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Mon, 25 Jan 2021 12:05:17 +0100 Subject: [PATCH 1/4] fix(nginx4spa): restrict envsub files type --- nginx4spa/envsub.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx4spa/envsub.sh b/nginx4spa/envsub.sh index 3f7e01f5c..1a185a5ba 100755 --- a/nginx4spa/envsub.sh +++ b/nginx4spa/envsub.sh @@ -21,7 +21,7 @@ echo "PORT=${PORT:="80"}" >> /tmp/env-vars while IFS='=' read -r KEY VALUE do # In every files in the dir, replace the environment variables value - find ${WWW_DIRECTORY} -type f -exec \ + find ${WWW_DIRECTORY} -type f -regex ".*\.\(conf\|txt\|html\|htm\|js\|css\)" -exec \ sed -i -e "s|${DELIMITER}${KEY}${DELIMITER}|${VALUE}|g" {} \; # replace in nginx.conf too sed -i -e "s|${DELIMITER}${KEY}${DELIMITER}|${VALUE}|g" /etc/nginx/nginx.conf From 5633a7f625243e52e27594fc077842e716ac68b8 Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Fri, 26 Feb 2021 18:36:02 +0100 Subject: [PATCH 2/4] Create bar.png --- nginx4spa/test/fixtures/foo/bar/bar.png | 1 + 1 file changed, 1 insertion(+) create mode 100644 nginx4spa/test/fixtures/foo/bar/bar.png diff --git a/nginx4spa/test/fixtures/foo/bar/bar.png b/nginx4spa/test/fixtures/foo/bar/bar.png new file mode 100644 index 000000000..66eabfa71 --- /dev/null +++ b/nginx4spa/test/fixtures/foo/bar/bar.png @@ -0,0 +1 @@ +// nginx4spa/test/foo/bar/bar.png with VERSION=%%VERSION%% From 0bf121173e32d1507665d9fca1349f7841bb0709 Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Fri, 26 Feb 2021 18:36:58 +0100 Subject: [PATCH 3/4] Update envsub.bats --- nginx4spa/test/envsub.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nginx4spa/test/envsub.bats b/nginx4spa/test/envsub.bats index 35536ead3..4c0697250 100644 --- a/nginx4spa/test/envsub.bats +++ b/nginx4spa/test/envsub.bats @@ -31,3 +31,9 @@ teardown() { assert_output "// nginx4spa/test/foo/bar/bar.js with VERSION=x.y.z" ] assert_success } + +@test "should not replace the VERSION with x.y.z in foo/bar/bar.png" { + run wget -qO - localhost:8888/foo/bar/bar.png + assert_output "// nginx4spa/test/foo/bar/bar.png with VERSION==%%VERSION%%" ] + assert_success +} From 190fd7f864b270709eac9f4da56f30627167321f Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Fri, 26 Feb 2021 18:47:39 +0100 Subject: [PATCH 4/4] Update envsub.bats --- nginx4spa/test/envsub.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx4spa/test/envsub.bats b/nginx4spa/test/envsub.bats index 4c0697250..be5e35d63 100644 --- a/nginx4spa/test/envsub.bats +++ b/nginx4spa/test/envsub.bats @@ -34,6 +34,6 @@ teardown() { @test "should not replace the VERSION with x.y.z in foo/bar/bar.png" { run wget -qO - localhost:8888/foo/bar/bar.png - assert_output "// nginx4spa/test/foo/bar/bar.png with VERSION==%%VERSION%%" ] + assert_output "// nginx4spa/test/foo/bar/bar.png with VERSION=%%VERSION%%" ] assert_success }