Skip to content

Commit abf32b6

Browse files
committed
Fix a parse bug with a quoted line with col_sep and an empty line
GitHub: fix GH-324 This is introduced by bb93c28. We can't reuse `row` in this case because `row` is used for the next row. Reported by stoodfarback. Thanks!!!
1 parent 61b7237 commit abf32b6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/csv/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def parse_quotable_robust(&block)
10411041
quoted_fields << @quoted_column_value
10421042
elsif parse_row_end
10431043
if row.empty? and value.nil?
1044-
emit_row(row, &block) unless @skip_blanks
1044+
emit_row([], &block) unless @skip_blanks
10451045
else
10461046
row << value
10471047
quoted_fields << @quoted_column_value

test/csv/parse/test_general.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,15 @@ def test_seeked_string_io
322322
CSV.new(input_with_bom).each.to_a)
323323
end
324324

325+
def test_quoted_col_sep_and_empty_line
326+
assert_equal([["one,"], [], ["three"]],
327+
CSV.parse(<<-CSV))
328+
"one,"
329+
330+
"three"
331+
CSV
332+
end
333+
325334
private
326335

327336
{

0 commit comments

Comments
 (0)