-
-
Notifications
You must be signed in to change notification settings - Fork 922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File.open() on Windows without binary flag reading 0x0A (newline) instead of 0x0D (return) #5100
Comments
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. |
Yeah that makes sense. Just wanted to give a bit of background as to how I came across the issue, agree it should be rb - felt worthy of reporting as the bare CR translation seems to be different from from cruby is all. Thanks for looking into this! :) |
I believe this is the commit in CRuby that changed from universal newline conversion (which does CR) to CRLF newline conversion (which only does CRLF): f9a6a1dd0c6 I believe most of the remaining plumbing exists in JRuby but this change was missed. |
See ruby/ruby@f9a6a1dd0c6 for the change in CRuby. The remaining plumbing in this commit needs to be reviewed.
@thomas- It should be fixed. Unfortunately nightly builds aren't running at the moment, but once they are (or you build yourself) you should be able to confirm it. Perhaps you could also add a quick spec to https://github.com/spec/ruby? |
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.
Environment
Expected Behavior
Script:
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
Actual Behavior
JRuby under windows instead outputs:
The text was updated successfully, but these errors were encountered: