When decrypting streaming and splitting files per line appears to loose \r\n or \n line endings when using Reader#read(1024).
Using without the limit doesn't lose the line endings.
Affected code
Bzip2::FFI::Reader.open(io_or_path) do |reader|
while buffer = reader.read(1024) do
line = buffer.split("\n")
# process uncompressed line from the buffer
end
end
Work around
Bzip2::FFI::Reader.open(io_or_path) do |reader|
while buffer = reader.read do
line = buffer.split("\n")
# process uncompressed line from the buffer
end
end
The issue might be somewhere around the code paths for default 4kb vs limit branch of read.
https://github.com/philr/bzip2-ffi/blob/7202391117e6709bc67404c1f55d4a3f5d3bc791/lib/bzip2/ffi/reader.rb#L311C1-L321C57
When decrypting streaming and splitting files per line appears to loose
\r\nor\nline endings when usingReader#read(1024).Using without the limit doesn't lose the line endings.
Affected code
Work around
The issue might be somewhere around the code paths for default 4kb vs limit branch of read.
https://github.com/philr/bzip2-ffi/blob/7202391117e6709bc67404c1f55d4a3f5d3bc791/lib/bzip2/ffi/reader.rb#L311C1-L321C57