From: "tenderlovemaking (Aaron Patterson)" Date: 2012-05-24T10:31:56+09:00 Subject: [ruby-core:45203] [ruby-trunk - Bug #6487][Open] io_strip_bom does not take in to account short files Issue #6487 has been reported by tenderlovemaking (Aaron Patterson). ---------------------------------------- Bug #6487: io_strip_bom does not take in to account short files https://bugs.ruby-lang.org/issues/6487 Author: tenderlovemaking (Aaron Patterson) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0] If a file is too short, io_strip_bom will raise an exception because it's trying to convert nil to an integer. Here is an example: irb(main):001:0> File.open('foo', 'wb') {} => nil irb(main):002:0> File.new('foo', 'r:bom|utf-8').close TypeError: no implicit conversion from nil to integer from (irb):2:in `initialize' from (irb):2:in `new' from (irb):2 from /Users/aaron/.local/bin/irb:12:in `
' irb(main):003:0> I've attached tests, but I'm not sure the best way to fix. It seems like a pain. :-/ -- http://bugs.ruby-lang.org/