Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
File.open() on Windows without binary flag reading 0x0A (newline) instead of 0x0D (return) #5100
I ran into this bug using a ruby gem that does file uploads, when some gifs became very mangled, seems to be affecting only Windows JRuby from what I can tell.
My reason for reporting is mostly that it is a different outcome than what happens in other envs and in cruby.
Where 0d.bin is a simple file with following hex contents:
I tested behavior with JRuby under linux, CRuby under linux, and CRuby under windows, all of which output:
Gist with bin file at https://gist.github.com/thomas-/3aa435855b10c7bc728c17e65d0ee4d1
JRuby under windows instead outputs:
referenced this issue
Mar 21, 2018
I'm sure this is a carriage-return/line-feed translation bug. "b" mode, which does no such translation, is obviously working correctly here. "t" mode, the default, wants to normalize line terminators to line-feed, but obviously it should not be doing so for a bare carriage-return.
Ok, so first off a bit of pushback: if there's a library reading files from disk and it's not specifying
That in my mind downgrades the severity of this bug.
We will, of course, fix the text-mode mangling of CR.