ruby-changes:45795
From: naruse <ko1@a...>
Date: Sun, 12 Mar 2017 02:45:21 +0900 (JST)
Subject: [ruby-changes:45795] naruse:r57868 (ruby_2_4): merge revision(s) 57406: [Backport #13149]
naruse 2017-03-12 02:45:18 +0900 (Sun, 12 Mar 2017) New Revision: 57868 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57868 Log: merge revision(s) 57406: [Backport #13149] csv.rb: fix field_size_limit check * lib/csv.rb (CSV#shift): the last column is an Array in extended column since r55985. [ruby-dev:49964] [Bug #13149] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/lib/csv.rb branches/ruby_2_4/test/csv/test_csv_parsing.rb branches/ruby_2_4/version.h Index: ruby_2_4/lib/csv.rb =================================================================== --- ruby_2_4/lib/csv.rb (revision 57867) +++ ruby_2_4/lib/csv.rb (revision 57868) @@ -1927,7 +1927,7 @@ class CSV https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/csv.rb#L1927 if @io.eof? raise MalformedCSVError, "Unclosed quoted field on line #{lineno + 1}." - elsif @field_size_limit and csv.last.size >= @field_size_limit + elsif @field_size_limit and csv.last.sum(&:size) >= @field_size_limit raise MalformedCSVError, "Field size exceeded on line #{lineno + 1}." end # otherwise, we need to loop and pull some more data to complete the row Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 57867) +++ ruby_2_4/version.h (revision 57868) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.0" #define RUBY_RELEASE_DATE "2017-03-12" -#define RUBY_PATCHLEVEL 33 +#define RUBY_PATCHLEVEL 34 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/test/csv/test_csv_parsing.rb =================================================================== --- ruby_2_4/test/csv/test_csv_parsing.rb (revision 57867) +++ ruby_2_4/test/csv/test_csv_parsing.rb (revision 57868) @@ -209,6 +209,28 @@ class TestCSV::Parsing < TestCSV https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/csv/test_csv_parsing.rb#L209 field_size_limit: 2048 ) end + def test_field_size_limit_in_extended_column_not_exceeding + data = <<~DATA + "a","b" + " + 2 + ","" + DATA + assert_nothing_raised(CSV::MalformedCSVError) do + CSV.parse(data, field_size_limit: 4) + end + end + + def test_field_size_limit_in_extended_column_exceeding + data = <<~DATA + "a","b" + " + 2345 + ","" + DATA + assert_parse_errors_out(data, field_size_limit: 5) + end + private def assert_parse_errors_out(*args) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r57406 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/