Skip to content

Commit

Permalink
Merge pull request rails#51 from cablegram/master
Browse files Browse the repository at this point in the history
Ensure that commands and args are properly quoted if they contain spaces or reserved shell characters (on Windows).
  • Loading branch information
josh committed Sep 24, 2011
2 parents 232ccd1 + e88067a commit bfdd02d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/execjs/external_runtime.rb
Expand Up @@ -183,7 +183,10 @@ def sh(command)
if ExecJS.windows? if ExecJS.windows?
def shell_escape(*args) def shell_escape(*args)
# see http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection123121120120 # see http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection123121120120
args.map { |arg| arg.gsub(/([&|()<>^ "])/,'^\1') }.join(" ") args.map { |arg|
arg = %Q("#{arg.gsub('"','""')}") if arg.match(/[&|()<>^ "]/)
arg
}.join(" ")
end end
else else
def shell_escape(*args) def shell_escape(*args)
Expand Down

0 comments on commit bfdd02d

Please sign in to comment.