Skip to content

Commit 9be946f

Browse files
committed
Apply maintainer feedback: improve tests and clean up code
1 parent b455a09 commit 9be946f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/csv/parser.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,6 @@ def prepare_quoted
675675
def prepare_unquoted
676676
return if @quote_character.nil?
677677

678-
# Only exclude characters that are actually part of the row separator
679-
# instead of hardcoding "\r\n"
680678
no_unquoted_values = Regexp.escape(@row_separator).encode(@encoding)
681679
no_unquoted_values << @escaped_first_column_separator
682680
unless @liberal_parsing

test/csv/parse/test_general.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ def test_unquoted_cr_with_custom_row_separator
156156
assert_equal(expected, CSV.parse(data, row_sep: "|"))
157157
end
158158

159-
def test_unquoted_cr_rejected_when_included_in_row_separator
159+
def test_unquoted_cr_with_crlf_row_separator
160160
data = "field1,field\r2,field3\r\nrow2,data,here\r\n"
161-
assert_raise(CSV::MalformedCSVError) do
161+
error = assert_raise(CSV::MalformedCSVError) do
162162
CSV.parse(data, row_sep: "\r\n")
163163
end
164+
assert_equal("Unquoted fields do not allow new line <\"\\r\"> in line 1.",
165+
error.message)
164166
end
165167

166168
def test_quoted_cr_with_custom_row_separator

0 commit comments

Comments
 (0)