-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Environment Information
Failing in both latest JRuby 9.4.14.0 and 10.0.2.0
For context, this started as a Rails file-upload (windows-1252) encoding issue.
Rack's multi-part implementation re-uses a String.new buffer and the incorrect code-range (upon second or later read) ends up causing an ArgumentError: invalid byte sequence in UTF-8.
tmpfile = Tempfile.new('file')
tmpfile.open
tmpfile.write("0123456789", tmpfile.path)
tmpfile.flush
tmpfile.close
### ------------------------------------------------
buf.concat "¿Cómo estás? Ça va bien?"
puts buf.ascii_only? # false
# open and read from a file with ASCII only content e.g.
File.open(tmpfile.path, encoding: 'binary') do |file|
file.read(10, buf) # read less than buf.size
end
tmpfile.delete
puts buf.inspect
puts buf.ascii_only? # true on MRI but false on JRubyThe last ascii_only? check fails as the code-range is not cleared upon re-using the buffer on IO#read.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels