Project

General

Profile

Actions

Bug #13149

closed

Ruby 2.4.0 の CSV の field_size_limit オプションで先読み文字数を制限できない

Added by koshigoe (Masataka SUZUKI) almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
[ruby-dev:49964]

Description

Ruby 2.4.0 から、指定文字数未満で例外が出る事も、指定文字数以上で例外が出ない事もあります。

以下、指定文字数未満で例外が出るケース。

require 'csv'

CSV.new(DATA, field_size_limit: 4).each { |x| p x }

__END__
"a","b"
"
2
",""
$ ruby test.rb
["a", "b"]
~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1931:in `block in shift': Field size exceeded on line 2. (CSV::MalformedCSVError)
        from ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1828:in `loop'
        from ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1828:in `shift'
        from ~/.rbenv/versions/2.4.0/lib/ruby/2.4.0/csv.rb:1770:in `each'
        from test.rb:3:in `<main>'

以下、指定文字数以上で例外が出ないケース。

require 'csv'

CSV.new(DATA, field_size_limit: 5).each { |x| p x }

__END__
"a","b"
"
2345
",""
$ ruby test.rb
["a", "b"]
["\n2345\n", ""]

Updated by koshigoe (Masataka SUZUKI) almost 8 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Status changed from Open to Closed

Applied in changeset r57406.


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]

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Description updated (diff)
  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r57868 merged revision(s) 57406.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0