liquid_xlsx 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4a2f29e44a564a50870b6f4c7d066dbb2d648a5ce1031a31115c3087f968710
4
- data.tar.gz: d1c8cbddb4f24c831cd7ada7cf5089814b615a72fa1f788828cddefce67a3dcf
3
+ metadata.gz: 2962349e5fe1197bffc9c0d28d21be73e83b97f71cf3e8ce86579c07246e5072
4
+ data.tar.gz: 67d36e10dfaf54790ffd949e175ba80b24940d331eb9e9b826661158b32c08ee
5
5
  SHA512:
6
- metadata.gz: 503a440465922dbf924b017ecbd7f7a532ac695a861cffe9cf64fc3ae97603e73a961f645eb20737ac95f93901b62970222d24e20cfc004dc6ec18eeed2ea97e
7
- data.tar.gz: 6f4f7399389a693dcd85af3fe4380e706783db5c4034133a4182a1445de4d3979ac535533e36b422aeeb720168cbe6dc0b85768be54a7557459037471c8c8ab5
6
+ metadata.gz: 5f9379732f56d318bb9dba0a0fbf5a9c82e2ec782a97109043eaf6e5272aeb4a2a5eb3b7fa592dbab1d059543ba5dc3dbf3f9fdbc1637bf7c9df42ecacec88ce
7
+ data.tar.gz: '080cdb56014357ece810afd62e5e42271f7eb403cdcd62cb63697f894b4814b67b6c2959f11dd911dc98099b5be18e715b0cdc1c27b16cbe95c3b92e6862450f'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.0 (unreleased)
3
+ ## 0.2.1 (2026-08-09)
4
+
5
+ ### Fixed
6
+
7
+ - Rendered workbooks are no longer marked ZIP64. Members were streamed without
8
+ a declared size, and rubyzip 3 — where ZIP64 is on by default — then flagged
9
+ every member as ZIP64: version 4.5 in the local header and `0xFFFFFFFF`
10
+ sizes. Such an archive still satisfies rubyzip and `unzip`, but Excel reports
11
+ a corrupt file and LibreOffice 7.4 fails with "source file could not be
12
+ loaded", which also broke conversion to PDF. Newer LibreOffice reads ZIP64,
13
+ so the breakage only surfaced on hosts with an older build. The member size
14
+ is known at write time and is now declared up front, which keeps ordinary
15
+ local headers. rubyzip 2.x was never affected: ZIP64 is off by default there.
16
+
17
+ ## 0.2.0 (2026-08-04)
4
18
 
5
19
  ### Fixed
6
20
 
@@ -23,6 +23,17 @@ module LiquidXlsx
23
23
  name == :create && %i[key keyreq].include?(type)
24
24
  end
25
25
 
26
+ # rubyzip 3 turned ZIP64 on by default. Streaming a member gives it no size
27
+ # up front, so it marks EVERY member as ZIP64 — version 4.5 in the local
28
+ # header and 0xFFFFFFFF sizes. Such an .xlsx is rejected by Excel and by
29
+ # LibreOffice builds without ZIP64 support (7.4 fails, 26.2 reads it).
30
+ # Here the member content is fully known, so the size can be declared up
31
+ # front and Entry#prep_local_zip64_extra leaves an ordinary header alone.
32
+ # rubyzip 2.x has no `size:` keyword, but there ZIP64 is off by default.
33
+ ZIP_SIZE_KEYWORD = Zip::File.instance_method(:get_output_stream).parameters.any? do |type, name|
34
+ name == :size && %i[key keyreq].include?(type)
35
+ end
36
+
26
37
  # Guard rails against zip bombs / resource exhaustion when unpacking.
27
38
  MAX_ENTRIES = 10_000
28
39
  MAX_ENTRY_UNCOMPRESSED = 512 * 1024 * 1024 # 512 MB per entry
@@ -107,7 +118,7 @@ module LiquidXlsx
107
118
  @files.each do |name, content|
108
119
  next if content.nil? # directories
109
120
 
110
- zip.get_output_stream(name) { |f| f.write(content) }
121
+ write_entry(zip, name, content)
111
122
  end
112
123
  end
113
124
  end
@@ -443,6 +454,17 @@ module LiquidXlsx
443
454
 
444
455
  private
445
456
 
457
+ # The size is declared in bytes: String#size counts characters, so on UTF-8
458
+ # content it would disagree with what actually gets written.
459
+ # See ZIP_SIZE_KEYWORD — rubyzip 2.x has no such keyword and needs none.
460
+ def write_entry(zip, name, content)
461
+ if ZIP_SIZE_KEYWORD
462
+ zip.get_output_stream(name, size: content.bytesize) { |f| f.write(content) }
463
+ else
464
+ zip.get_output_stream(name) { |f| f.write(content) }
465
+ end
466
+ end
467
+
446
468
  # Open a brand-new archive for writing across rubyzip 2.x and 3.x.
447
469
  # See ZIP_CREATE_KEYWORD for why the call has to be spelled two ways.
448
470
  def open_new_zip(output_path, &)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LiquidXlsx
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid_xlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Khlipitkin