Project

General

Profile

This project is closed and read-only.

Actions

Backport #6487

closed

io_strip_bom does not take in to account short files

Backport #6487: io_strip_bom does not take in to account short files

Added by tenderlovemaking (Aaron Patterson) over 14 years ago. Updated over 14 years ago.

Status:
Closed
Assignee:
-
[ruby-core:45203]

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

bad_bom.patch (1.44 KB) bad_bom.patch tenderlovemaking (Aaron Patterson), 05/24/2012 10:31 AM
Actions

Also available in: PDF Atom