Bug #1075: \r\n と \n が混在した CSV がエラーになる
http://redmine.ruby-lang.org/issues/show/1075

起票者: Masahiro Tomita
ステータス: Open, 優先度: Normal
カテゴリ: lib
ruby -v: ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

"a,\"b\n\",c\r\n" を CSV.new に渡すとエラーになります。

$ ruby -v -rcsv -e 'p CSV.parse("a,\"b\n\",c\r\n")'
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
/usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1863:in `block (2 levels) in shift': Unquoted fields do not allow \r or \n (line 1). (CSV::MalformedCSVError)
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1853:in `gsub!'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1853:in `block in shift'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1815:in `loop'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1815:in `shift'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1760:in `each'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1771:in `to_a'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1771:in `read'
        from /usr/local/ruby-1.9.1/lib/ruby/1.9.1/csv.rb:1360:in `parse'
        from -e:1:in `<main>'

1.8.7 ではエラーになりません。

$ ruby -v -rcsv -e 'p CSV.parse("a,\"b\n\",c\r\n")'
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
[["a", "b\n", "c"]]


----------------------------------------
http://redmine.ruby-lang.org