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:
parent
2b6a9f3a1f
commit
43a16c98df
Notes:
git
2019-09-27 23:44:02 +09:00
2 changed files with 6 additions and 1 deletions
|
@ -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 = " "
|
||||
|
|
Loading…
Add table
Reference in a new issue