Fixed #168. Rubyzip changed default behavior.#170
Fixed #168. Rubyzip changed default behavior.#170abartov wants to merge 2 commits intoruby-docx:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #168 by disabling ZIP64 support in rubyzip to fix compatibility issues with file saving. Rubyzip 3.x changed its default behavior to enable ZIP64 by default, which causes problems with tools like pandoc that don't support ZIP64 for small files. The fix adds a global configuration setting to disable ZIP64 support.
- Adds global configuration
Zip.write_zip64_support = falseto disable ZIP64 - Includes explanatory comments about rubyzip 3.x default behavior change
- Aims to restore compatibility with readers that don't support ZIP64
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/docx/document.rb
Outdated
| # Disable ZIP64 support to maintain compatibility with version 0.9.1 and | ||
| # ensure compatibility with all readers. Rubyzip 3.x enables ZIP64 by default, | ||
| # but many readers (including pandoc) don't support it for small files. | ||
| Zip.write_zip64_support = false |
There was a problem hiding this comment.
Setting global Zip configuration in a library gem is problematic. This modifies global state for all code using rubyzip in the consuming application, potentially breaking other functionality that may need ZIP64 support.
Consider investigating per-operation ZIP64 configuration instead of global configuration. If rubyzip 3.x doesn't support per-operation configuration, consider:
- Documenting this global configuration change prominently in README and CHANGELOG
- Providing a configuration option that allows users to opt-in/out of this behavior
- Only setting this configuration in the
saveandstreammethods and restoring it afterwards
This approach would minimize side effects on other code while achieving the same compatibility goal.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The issue with file saving was that Rubyzip 3.x now saves ZIP64 by default. This is unexpected and unsupported by many tools, and best not to enable by default in docx.
I'd appreciate it if the maintainers merge this and release a new gem.