Actions
Backport #6487
closedio_strip_bom does not take in to account short files
Status:
Closed
Assignee:
-
Description
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. :-/
Files
Actions
Like0
Like0Like0Like0Like0