1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Do not escape + in Shellwords.escape

+ is not a character that requires escaping in Bourne sh.

Fixes [Bug #14429]
This commit is contained in:
Jeremy Evans 2019-06-20 13:19:48 -07:00
parent 2b6a9f3a1f
commit 43a16c98df
Notes: git 2019-09-27 23:44:02 +09:00
2 changed files with 6 additions and 1 deletions

View file

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

View file

@ -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 = " "