From 832b7f3c547377621e920704c3e4dd839d21f0af Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 23 Nov 2020 05:54:04 +0900 Subject: [PATCH] [ruby/csv] Add support for \r\n with skip_lines: /...$/ again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub: fix GH-194 Reported by Josef Šimánek. Thanks!!! https://github.com/ruby/csv/commit/fd86afe081 --- lib/csv/parser.rb | 1 + test/csv/parse/test_skip_lines.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb index 68fe238194..2fb3b0a46e 100644 --- a/lib/csv/parser.rb +++ b/lib/csv/parser.rb @@ -785,6 +785,7 @@ class CSV end def skip_line?(line) + line = line.delete_suffix(@row_separator) case @skip_lines when String line.include?(@skip_lines) diff --git a/test/csv/parse/test_skip_lines.rb b/test/csv/parse/test_skip_lines.rb index 2f7e6c8ddd..98d67ae51c 100644 --- a/test/csv/parse/test_skip_lines.rb +++ b/test/csv/parse/test_skip_lines.rb @@ -109,4 +109,10 @@ class TestCSVParseSkipLines < Test::Unit::TestCase :liberal_parsing => true, :skip_lines => /^$/)) end + + def test_crlf + assert_equal([["a", "b"]], + CSV.parse("a,b\r\n,\r\n", + :skip_lines => /^,+$/)) + end end