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

Use \& instead of \1 with capture

This commit is contained in:
Kazuhiro NISHIYAMA 2019-10-17 12:51:29 +09:00
parent d5744aff3a
commit 37457117c9
No known key found for this signature in database
GPG key ID: 262ED8DBB4222F7A

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]/, "\\\\\\&")
# A LF cannot be escaped with a backslash because a backslash + LF
# combo is regarded as a line continuation and simply ignored.