omnizip 0.4.13 → 0.4.14

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: 06d2f81fd343badad973d8d2ed3804f9b0ec7305cf0e36fef017f1a5bff69501
4
- data.tar.gz: 1594621c5ac3dc538e85fedca9c14a32b8fa54fd5fc89443b58662ba7a6deef7
3
+ metadata.gz: aba369737bae1af11e56961a295caaa6ac0872818344dace5338a3516567c13f
4
+ data.tar.gz: bb136a172846b4f63e6a494872ba11dc1f297430d1306bd4d089ffdda85c10cb
5
5
  SHA512:
6
- metadata.gz: 908629a2058b5fb4366349cb2fae9630e3909c193e6062d33e812e5357f74801a236304cb6752aaa96ef037eb96b7c2cb90feea144876b46189cee92eb751863
7
- data.tar.gz: 5785b580543607ec9691e454fdd181e360a568457cfbd5c3d0b874368f64bd88b42b2b88ab342bfab57b27ae374ed83e5f137805cf950b860e1b9b4606a86e8d
6
+ metadata.gz: bc31967cbabf5e6053612592774468509f678e36300a6dace46aad30ab35f44a5b8efaa0fc680bb33dae581b745663d7a881f51998fbdf4c3ca0d4326880875a
7
+ data.tar.gz: a6adc71d9f395e22d3b2ff842ccdc2735a5913e15c058d1b6d96d7f11387a09d7ae6971b7f167131a467069ba2bb08881905e1a5c9aabed4b1882a76b6333c05
@@ -181,7 +181,7 @@ module Omnizip
181
181
  end
182
182
 
183
183
  offset = 46
184
- filename = data[offset, filename_length].force_encoding("UTF-8")
184
+ filename = Filename.decode(data[offset, filename_length], flags)
185
185
  offset += filename_length
186
186
 
187
187
  extra_field = data[offset, extra_field_length]
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omnizip
4
+ module Formats
5
+ module Zip
6
+ # An entry name is UTF-8 only when the entry's general-purpose flag
7
+ # (bit 11) says so. Without the flag the name is in the writer's code
8
+ # page — CP932 for the Japanese vendor archives that fail extraction —
9
+ # and forcing UTF-8 on those bytes yields a string the filesystem
10
+ # refuses with Errno::EILSEQ (fontist/fontist#379).
11
+ module Filename
12
+ # Legacy code page assumed for an unflagged name that is not valid
13
+ # UTF-8. ASCII names decode identically under every code page.
14
+ FALLBACK_ENCODING = Encoding::CP932
15
+
16
+ module_function
17
+
18
+ def decode(bytes, flags)
19
+ if flags.anybits?(Constants::FLAG_UTF8)
20
+ return bytes.dup.force_encoding(Encoding::UTF_8).scrub
21
+ end
22
+
23
+ utf8 = bytes.dup.force_encoding(Encoding::UTF_8)
24
+ return utf8 if utf8.valid_encoding?
25
+
26
+ fallback = bytes.dup.force_encoding(FALLBACK_ENCODING)
27
+ return fallback.encode(Encoding::UTF_8) if fallback.valid_encoding?
28
+
29
+ utf8.scrub
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -104,7 +104,7 @@ module Omnizip
104
104
  end
105
105
 
106
106
  offset = 30
107
- filename = data[offset, filename_length].force_encoding("UTF-8")
107
+ filename = Filename.decode(data[offset, filename_length], flags)
108
108
  offset += filename_length
109
109
 
110
110
  extra_field = data[offset, extra_field_length]
@@ -19,6 +19,7 @@ module Omnizip
19
19
  autoload :Reader, "omnizip/formats/zip/reader"
20
20
  autoload :Writer, "omnizip/formats/zip/writer"
21
21
  autoload :UnixExtraField, "omnizip/formats/zip/unix_extra_field"
22
+ autoload :Filename, "omnizip/formats/zip/filename"
22
23
 
23
24
  class << self
24
25
  # Read a ZIP archive
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Omnizip
4
- VERSION = "0.4.13"
4
+ VERSION = "0.4.14"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnizip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.13
4
+ version: 0.4.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-24 00:00:00.000000000 Z
11
+ date: 2026-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -528,6 +528,7 @@ files:
528
528
  - lib/omnizip/formats/zip/central_directory_header.rb
529
529
  - lib/omnizip/formats/zip/constants.rb
530
530
  - lib/omnizip/formats/zip/end_of_central_directory.rb
531
+ - lib/omnizip/formats/zip/filename.rb
531
532
  - lib/omnizip/formats/zip/local_file_header.rb
532
533
  - lib/omnizip/formats/zip/reader.rb
533
534
  - lib/omnizip/formats/zip/unix_extra_field.rb