aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/shellwords.rb2
-rw-r--r--test/test_shellwords.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/shellwords.rb b/lib/shellwords.rb
index eb5fa2d226..a125b8968c 100644
--- a/lib/shellwords.rb
+++ b/lib/shellwords.rb
@@ -147,7 +147,7 @@ module Shellwords
# Treat multibyte characters as is. It is the caller's responsibility
# to encode the string in the right encoding for the shell
# environment.
- str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1")
+ str.gsub!(/([^A-Za-z0-9_\-.,:+\/@\n])/, "\\\\\\1")
# A LF cannot be escaped with a backslash because a backslash + LF
# combo is regarded as a line continuation and simply ignored.
diff --git a/test/test_shellwords.rb b/test/test_shellwords.rb
index 16949c02d3..86971b7237 100644
--- a/test/test_shellwords.rb
+++ b/test/test_shellwords.rb
@@ -68,6 +68,11 @@ class TestShellwords < Test::Unit::TestCase
assert_equal "ps -p #{$$}", joined
end
+ def test_shellescape
+ assert_equal "''", shellescape('')
+ assert_equal "\\^AZaz09_\\\\-.,:/@'\n'+\\'\\\"", shellescape("^AZaz09_\\-.,:\/@\n+'\"")
+ end
+
def test_whitespace
empty = ''
space = " "