weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.27k stars 253 forks source link

Prevent `#parse_buffer` from altering input buffer #454

Closed HosokawaR closed 5 months ago

HosokawaR commented 5 months ago

Fixes #453 This PR prevent #parse_buffer from altering input buffer.

As stated in the issue, it is more intuitive for parse_buffer to not change the input buffer. However, the internal call Zip::File.open_buffer changes the input buffer if called with block. Therefore, I changed the calling method so that it does not use block.

weshatheleopard commented 5 months ago

You see, I'm temped to NOT do anything about this issue in RubyXL since all that it does is passing the buffer to RubyZip; from that point, it's RubyZip responsebility: if it modifies buffer, it's it's fault, not RubyXLs. I do not appreciate this behavior, as there's no reason why it should ever modify the buffer, but that's what they do. I figured out that when I pass a String to RubyZip, then .freeze'ing it before passing it over does the trick. I don't have a problem adding a warning about that to the documentation. But I think RubyZip's issues need to be handled with its developers.

HosokawaR commented 5 months ago

Thank you for your reply.

it's RubyZip responsebility:

I agree. This PR will be closed for now.