Skip to content
This repository

Don't quote shell escaped values. #258

Merged
merged 2 commits into from over 1 year ago

5 participants

Kevin McAllister David Dollar Marc Boeker Laust Rud Jacobsen Matt Griffin
Kevin McAllister

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."

David Dollar
Owner

Thanks for the pull request! I'd be happy to merge this if you could rebase it to master and fix up the tests.

Marc Boeker

Thanks!

Kevin McAllister

Sure. Sorry about the tests. I'll get that cleaned up.

Kevin McAllister

I fixed up the tests.

And I think I rebased it correctly. Thanks.

David Dollar
Owner

Thanks!

Laust Rud Jacobsen

See also #112, seems related

Matt Griffin

What can we do to help get this pulled? (cc/@jjrussell)

David Dollar ddollar merged commit 88cdaac into from January 14, 2013
David Dollar ddollar closed this January 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 2 authors.

Sep 14, 2012
Kevin McAllister 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."
7b4eabf
Kevin McAllister Remove expectation of double quotes around environment variables from
test comparisons
8fbee31
This page is out of date. Refresh to see the latest.
2  lib/foreman/export/base.rb
@@ -91,7 +91,7 @@ def clean(filename)
91 91
   end
92 92
 
93 93
   def shell_quote(value)
94  
-    '"' + Shellwords.escape(value) + '"'
  94
+    Shellwords.escape(value)
95 95
   end
96 96
 
97 97
   # deprecated
2  spec/foreman/export/upstart_spec.rb
@@ -38,7 +38,7 @@
38 38
     engine.env['KEY'] = 'd"\|d'
39 39
     upstart.export
40 40
     "foobarfoo".should include "bar"
41  
-    File.read("/tmp/init/app-alpha-1.conf").should =~ /KEY="d\\"\\\\\\\|d/
  41
+    File.read("/tmp/init/app-alpha-1.conf").should =~ /KEY=d\\"\\\\\\\|d/
42 42
   end
43 43
 
44 44
   context "with a formation" do
4  spec/resources/export/supervisord/app-alpha-1.conf
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log
8 8
 stderr_logfile=/var/log/app/alpha-1.error.log
9 9
 user=app
10 10
 directory=/tmp/app
11  
-environment=PORT="5000"
  11
+environment=PORT=5000
12 12
 [program:app-bravo-1]
13 13
 command=./bravo
14 14
 autostart=true
@@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/bravo-1.log
18 18
 stderr_logfile=/var/log/app/bravo-1.error.log
19 19
 user=app
20 20
 directory=/tmp/app
21  
-environment=PORT="5100"
  21
+environment=PORT=5100
22 22
 
23 23
 [group:app]
24 24
 programs=app-alpha-1,app-bravo-1
4  spec/resources/export/supervisord/app-alpha-2.conf
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log
8 8
 stderr_logfile=/var/log/app/alpha-1.error.log
9 9
 user=app
10 10
 directory=/tmp/app
11  
-environment=PORT="5000"
  11
+environment=PORT=5000
12 12
 [program:app-alpha-2]
13 13
 command=./alpha
14 14
 autostart=true
@@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/alpha-2.log
18 18
 stderr_logfile=/var/log/app/alpha-2.error.log
19 19
 user=app
20 20
 directory=/tmp/app
21  
-environment=PORT="5001"
  21
+environment=PORT=5001
22 22
 
23 23
 [group:app]
24 24
 programs=app-alpha-1,app-alpha-2
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.