mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
8c0edbd79d
commit
198281a71d
2 changed files with 31 additions and 1 deletions
|
@ -429,7 +429,7 @@ class CSV
|
||||||
end
|
end
|
||||||
@need_robust_parsing = true
|
@need_robust_parsing = true
|
||||||
elsif @strip
|
elsif @strip
|
||||||
strip_values = " \t\r\n\f\v"
|
strip_values = " \t\f\v"
|
||||||
@escaped_strip = strip_values.encode(@encoding)
|
@escaped_strip = strip_values.encode(@encoding)
|
||||||
if @quote_character
|
if @quote_character
|
||||||
@strip_value = Regexp.new("[#{strip_values}]+".encode(@encoding))
|
@strip_value = Regexp.new("[#{strip_values}]+".encode(@encoding))
|
||||||
|
|
|
@ -45,4 +45,34 @@ class TestCSVParseStrip < Test::Unit::TestCase
|
||||||
strip: %Q{"},
|
strip: %Q{"},
|
||||||
quote_char: nil))
|
quote_char: nil))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_do_not_strip_cr
|
||||||
|
assert_equal([
|
||||||
|
["a", "b "],
|
||||||
|
["a", "b "],
|
||||||
|
],
|
||||||
|
CSV.parse(%Q{"a" ,"b " \r} +
|
||||||
|
%Q{"a" ,"b " \r},
|
||||||
|
strip: true))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_do_not_strip_lf
|
||||||
|
assert_equal([
|
||||||
|
["a", "b "],
|
||||||
|
["a", "b "],
|
||||||
|
],
|
||||||
|
CSV.parse(%Q{"a" ,"b " \n} +
|
||||||
|
%Q{"a" ,"b " \n},
|
||||||
|
strip: true))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_do_not_strip_crlf
|
||||||
|
assert_equal([
|
||||||
|
["a", "b "],
|
||||||
|
["a", "b "],
|
||||||
|
],
|
||||||
|
CSV.parse(%Q{"a" ,"b " \r\n} +
|
||||||
|
%Q{"a" ,"b " \r\n},
|
||||||
|
strip: true))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue