Index: lib/csv.rb =================================================================== --- lib/csv.rb (working copy) +++ lib/csv.rb (working copy) @@ -1904,6 +1904,9 @@ return line when @col_sep return line << nil + when @col_sep_quote + buf = @quote_char + next end break unless buf.slice!(0, @col_sep.size) == @col_sep @@ -1968,19 +1971,23 @@ return unless @data_buf = @io.gets(@quote_char, @io_read_limit) end - loop do - if newline = @data_buf.index(@row_sep) - break if newline == @data_buf.size - @row_sep.size - return @data_buf.slice!(0, newline + @row_sep.size) - end + case @data_buf + when @col_sep_quote, @quote_char + else + loop do + if newline = @data_buf.index(@row_sep) + break if newline == @data_buf.size - @row_sep.size + return @data_buf.slice!(0, newline + @row_sep.size) + end - break if @io.eof? || @data_buf.end_with?(@quote_char) + break if @io.eof? || @data_buf.end_with?(@quote_char) - if @field_size_limit && @data_buf.size > @field_size_limit - raise MalformedCSVError, "Field size exceeded on line #{@lineno}." - end + if @field_size_limit && @data_buf.size > @field_size_limit + raise MalformedCSVError, "Field size exceeded on line #{@lineno}." + end - @data_buf += @io.gets(@quote_char, @io_read_limit) unless align_data_buf + @data_buf += @io.gets(@quote_char, @io_read_limit) unless align_data_buf + end end return_buf = @data_buf @@ -2104,6 +2111,7 @@ @field_size_limit = options.delete(:field_size_limit) @io_read_limit = options.delete(:io_read_limit) @nl_lf = encode_str("\r\n") + @col_sep_quote = @col_sep + @quote_char end #