* lib/shellwords.rb (Shellwords#shellsplit): Fix a bug where
consecutive backslashes in double quotes are all removed except the one at the tail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
44d20d61c7
commit
8c72fc9bf0
@ -1,3 +1,9 @@
|
|||||||
|
Fri Jan 13 03:38:36 2012 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* lib/shellwords.rb (Shellwords#shellsplit): Fix a bug where
|
||||||
|
consecutive backslashes in double quotes are all removed except
|
||||||
|
the one at the tail.
|
||||||
|
|
||||||
Fri Jan 13 03:28:00 2012 Luis Lavena <luislavena@gmail.com>
|
Fri Jan 13 03:28:00 2012 Luis Lavena <luislavena@gmail.com>
|
||||||
|
|
||||||
* ext/socket/extconf.rb (if ipv6): only define _WIN32_WINNT if was not
|
* ext/socket/extconf.rb (if ipv6): only define _WIN32_WINNT if was not
|
||||||
|
@ -41,7 +41,7 @@ module Shellwords
|
|||||||
line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do
|
line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do
|
||||||
|word, sq, dq, esc, garbage, sep|
|
|word, sq, dq, esc, garbage, sep|
|
||||||
raise ArgumentError, "Unmatched double quote: #{line.inspect}" if garbage
|
raise ArgumentError, "Unmatched double quote: #{line.inspect}" if garbage
|
||||||
field << (word || sq || (dq || esc).gsub(/\\(?=.)/, ''))
|
field << (word || sq || (dq || esc).gsub(/\\(.)/, '\\1'))
|
||||||
if sep
|
if sep
|
||||||
words << field
|
words << field
|
||||||
field = ''
|
field = ''
|
||||||
|
@ -38,6 +38,15 @@ class TestShellwords < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_backslashes
|
||||||
|
cmdline, expected = [
|
||||||
|
%q{/a//b///c////d/////e/ "/a//b///c////d/////e/ "'/a//b///c////d/////e/ '/a//b///c////d/////e/ },
|
||||||
|
%q{a/b/c//d//e a/b/c//d//e /a//b///c////d/////e/ a/b/c//d//e }
|
||||||
|
].map { |str| str.tr("/", "\\\\") }
|
||||||
|
|
||||||
|
assert_equal [expected], shellwords(cmdline)
|
||||||
|
end
|
||||||
|
|
||||||
def test_multibyte_characters
|
def test_multibyte_characters
|
||||||
# This is not a spec. It describes the current behavior which may
|
# This is not a spec. It describes the current behavior which may
|
||||||
# be changed in future. There would be no multibyte character
|
# be changed in future. There would be no multibyte character
|
||||||
|
Loading…
x
Reference in New Issue
Block a user