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
Родитель 2b6a9f3a1f
Коммит 43a16c98df
2 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

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

Просмотреть файл

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