From 7b4eabf0c585f6b5b372ce786b5b6b0fad64d51e Mon Sep 17 00:00:00 2001 From: Kevin McAllister Date: Thu, 6 Sep 2012 15:13:21 -0400 Subject: [PATCH 1/2] Remove explicit wrapping of Shellwords.escape in double quotes According to http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellescape "Note that a resulted string should be used unquoted and is not intended for use in double quotes nor in single quotes." --- lib/foreman/export/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/foreman/export/base.rb b/lib/foreman/export/base.rb index 72dd464..5541006 100644 --- a/lib/foreman/export/base.rb +++ b/lib/foreman/export/base.rb @@ -91,7 +91,7 @@ private ###################################################################### end def shell_quote(value) - '"' + Shellwords.escape(value) + '"' + Shellwords.escape(value) end # deprecated From 8fbee31a2d3d7a0909b9cab9df5ca0d52ca6f9c2 Mon Sep 17 00:00:00 2001 From: Kevin McAllister Date: Fri, 14 Sep 2012 20:20:02 -0400 Subject: [PATCH 2/2] Remove expectation of double quotes around environment variables from test comparisons --- spec/foreman/export/upstart_spec.rb | 2 +- spec/resources/export/supervisord/app-alpha-1.conf | 4 ++-- spec/resources/export/supervisord/app-alpha-2.conf | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/foreman/export/upstart_spec.rb b/spec/foreman/export/upstart_spec.rb index 8c41d88..907564e 100644 --- a/spec/foreman/export/upstart_spec.rb +++ b/spec/foreman/export/upstart_spec.rb @@ -38,7 +38,7 @@ describe Foreman::Export::Upstart, :fakefs do engine.env['KEY'] = 'd"\|d' upstart.export "foobarfoo".should include "bar" - File.read("/tmp/init/app-alpha-1.conf").should =~ /KEY="d\\"\\\\\\\|d/ + File.read("/tmp/init/app-alpha-1.conf").should =~ /KEY=d\\"\\\\\\\|d/ end context "with a formation" do diff --git a/spec/resources/export/supervisord/app-alpha-1.conf b/spec/resources/export/supervisord/app-alpha-1.conf index d365588..26a2f8f 100644 --- a/spec/resources/export/supervisord/app-alpha-1.conf +++ b/spec/resources/export/supervisord/app-alpha-1.conf @@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log stderr_logfile=/var/log/app/alpha-1.error.log user=app directory=/tmp/app -environment=PORT="5000" +environment=PORT=5000 [program:app-bravo-1] command=./bravo autostart=true @@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/bravo-1.log stderr_logfile=/var/log/app/bravo-1.error.log user=app directory=/tmp/app -environment=PORT="5100" +environment=PORT=5100 [group:app] programs=app-alpha-1,app-bravo-1 diff --git a/spec/resources/export/supervisord/app-alpha-2.conf b/spec/resources/export/supervisord/app-alpha-2.conf index 2160314..74f3024 100644 --- a/spec/resources/export/supervisord/app-alpha-2.conf +++ b/spec/resources/export/supervisord/app-alpha-2.conf @@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log stderr_logfile=/var/log/app/alpha-1.error.log user=app directory=/tmp/app -environment=PORT="5000" +environment=PORT=5000 [program:app-alpha-2] command=./alpha autostart=true @@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/alpha-2.log stderr_logfile=/var/log/app/alpha-2.error.log user=app directory=/tmp/app -environment=PORT="5001" +environment=PORT=5001 [group:app] programs=app-alpha-1,app-alpha-2