rubyzip 3.5.0 → 3.6.0

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: 127a7ca4438d6d96f18b7f9699d47491e416ddcc6dbcc0bc8f83f8335a2d516c
4
- data.tar.gz: f305dbf4d5f909f1218f11c9400cf41b5645a20233ccdfec8b4416a533d558de
3
+ metadata.gz: 8ad461af594aaafc83f2a9af47a7e72681431835864534c174970e2245748764
4
+ data.tar.gz: 6c5bd535a0b049a606bd64ca90106e633c385926d91c32ca3db72314d2b031f0
5
5
  SHA512:
6
- metadata.gz: c7aaa339ad47862c661b1f284cb1bd38ae65583fb623b85307e20b79f3d871fb3d87254b3a183aee3ba52a16cf8865ed88118919f8997d966384a60c98141234
7
- data.tar.gz: d19bb9446945b5d5612e2b3c10dff6727f32d638fe738829ac7bcf5929d20e429683e76a3cc84543ae607c6e2d3941fcf104357e9d3d52670e0547667e43c849
6
+ metadata.gz: ecd014dee5b905fe5a85af4273e564a0abbdb9c75409a489363352999b2298bfa6baf311c4722c022ddd87807e402d2b9b03f54ec2c110a4cf8c882ed916d301
7
+ data.tar.gz: 7711a4b6bd467e46d020b9d36b58ad726c0ff312d2247e49c9030cbdfb53d206dd5e16ddbb265f34f3f9802c728de06517926de352db7fac8f43ceafd3a3f496
data/Changelog.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 3.6.0 (2026-09-01)
2
+
3
+ - Forward options from OutputStream.open without a block. [#674](https://github.com/rubyzip/rubyzip/pull/674)
4
+ - Clamp DOS date and time to the range the fields can hold. [#671](https://github.com/rubyzip/rubyzip/pull/671)
5
+
6
+ Tooling/internal:
7
+
8
+ - Unix owner ids no longer default to 0 (root).
9
+ - Legacy Unix owner ids no longer default to 0 (root).
10
+ - Handle short reads in `copy_stream_n`. [#675](https://github.com/rubyzip/rubyzip/pull/675)
11
+ - Retain required Zip64 offset fields. [#676](https://github.com/rubyzip/rubyzip/pull/676)
12
+ - Load openssl only when AES encryption is used. [#672](https://github.com/rubyzip/rubyzip/pull/672)
13
+
1
14
  # 3.5.0 (2026-08-18)
2
15
 
3
16
  - Fix the link to Ruby doc in README to the latest version. [#670](https://github.com/rubyzip/rubyzip/pull/670)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'openssl'
4
-
5
3
  module Zip
6
4
  module AESEncryption # :nodoc:
7
5
  VERIFIER_LENGTH = 2
@@ -45,6 +43,11 @@ module Zip
45
43
  }.freeze
46
44
 
47
45
  def initialize(password, strength)
46
+ # Loaded here rather than at the top of the file so that `require 'zip'`
47
+ # does not pull in openssl. Only AES-encrypted archives need it, and it
48
+ # is the single largest cost of loading this library.
49
+ require 'openssl'
50
+
48
51
  @password = password
49
52
  @strength = strength
50
53
  @bits = BITS[@strength]
data/lib/zip/dos_time.rb CHANGED
@@ -16,6 +16,18 @@ module Zip
16
16
  # bits 5-8 month (1-12)
17
17
  # bits 9-15 year (four digit year minus 1980)
18
18
 
19
+ # The MS-DOS date field is seven bits of "year minus 1980", so only
20
+ # 1980-01-01 00:00:00 through 2107-12-31 23:59:58 can be represented.
21
+ # Times outside that are clamped rather than allowed to wrap: the real
22
+ # time is still carried in the universal time (UT) extra field, but the
23
+ # DOS fields have to stay in range for readers that only look at those.
24
+ DOS_EPOCH_YEAR = 1980
25
+ DOS_MAX_YEAR = 2107
26
+ DOS_MIN_DATE = 0x0021 # 1980-01-01
27
+ DOS_MAX_DATE = 0xff9f # 2107-12-31
28
+ DOS_MIN_TIME = 0x0000 # 00:00:00
29
+ DOS_MAX_TIME = 0xbf7d # 23:59:58
30
+
19
31
  attr_writer :absolute_time # :nodoc:
20
32
 
21
33
  def absolute_time?
@@ -25,15 +37,21 @@ module Zip
25
37
  end
26
38
 
27
39
  def to_binary_dos_time
40
+ return DOS_MIN_TIME if year < DOS_EPOCH_YEAR
41
+ return DOS_MAX_TIME if year > DOS_MAX_YEAR
42
+
28
43
  (sec / 2) +
29
44
  (min << 5) +
30
45
  (hour << 11)
31
46
  end
32
47
 
33
48
  def to_binary_dos_date
49
+ return DOS_MIN_DATE if year < DOS_EPOCH_YEAR
50
+ return DOS_MAX_DATE if year > DOS_MAX_YEAR
51
+
34
52
  day +
35
53
  (month << 5) +
36
- ((year - 1980) << 9)
54
+ ((year - DOS_EPOCH_YEAR) << 9)
37
55
  end
38
56
 
39
57
  # Deprecated. Remove for version 4.
@@ -7,8 +7,8 @@ module Zip
7
7
  register_map
8
8
 
9
9
  def initialize(binstr = nil)
10
- @uid = 0
11
- @gid = 0
10
+ @uid = nil
11
+ @gid = nil
12
12
  @atime = nil
13
13
  @mtime = nil
14
14
  binstr && merge(binstr)
@@ -7,8 +7,8 @@ module Zip
7
7
  register_map
8
8
 
9
9
  def initialize(binstr = nil)
10
- @uid = 0
11
- @gid = 0
10
+ @uid = nil
11
+ @gid = nil
12
12
  binstr && merge(binstr)
13
13
  end
14
14
 
@@ -59,8 +59,8 @@ module Zip
59
59
  # We can suppress the zip64 extra field unless we know the size is large or
60
60
  # the relative header offset is large (for central directory entries).
61
61
  def suppress?
62
- !(@original_size && @original_size >= 0xFFFFFFFF) ||
63
- (@relative_header_offset && @relative_header_offset >= 0xFFFFFFFF)
62
+ !((@original_size && @original_size >= 0xFFFFFFFF) ||
63
+ (@relative_header_offset && @relative_header_offset >= 0xFFFFFFFF))
64
64
  end
65
65
 
66
66
  def pack_for_local
data/lib/zip/ioextras.rb CHANGED
@@ -13,8 +13,11 @@ module Zip
13
13
  toread = nbytes
14
14
  while toread > 0 && !istream.eof?
15
15
  tr = [toread, CHUNK_SIZE].min
16
- ostream.write(istream.read(tr, +''))
17
- toread -= tr
16
+ chunk = istream.read(tr, +'')
17
+ break if !chunk || chunk.empty?
18
+
19
+ ostream.write(chunk)
20
+ toread -= chunk.bytesize
18
21
  end
19
22
  end
20
23
  end
@@ -53,7 +53,13 @@ module Zip
53
53
  # stream is passed to the block and closed when the block
54
54
  # returns.
55
55
  def open(file_name, encrypter: nil, suppress_extra_fields: false)
56
- return new(file_name) unless block_given?
56
+ unless block_given?
57
+ return new(
58
+ file_name,
59
+ encrypter: encrypter,
60
+ suppress_extra_fields: suppress_extra_fields
61
+ )
62
+ end
57
63
 
58
64
  zos = new(file_name, stream: false, encrypter: encrypter,
59
65
  suppress_extra_fields: suppress_extra_fields)
data/lib/zip/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Zip
4
4
  # The version of the Rubyzip library.
5
- VERSION = '3.5.0'
5
+ VERSION = '3.6.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Haines
@@ -196,9 +196,9 @@ licenses:
196
196
  - BSD-2-Clause
197
197
  metadata:
198
198
  bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
199
- changelog_uri: https://github.com/rubyzip/rubyzip/blob/v3.5.0/Changelog.md
200
- documentation_uri: https://www.rubydoc.info/gems/rubyzip/3.5.0
201
- source_code_uri: https://github.com/rubyzip/rubyzip/tree/v3.5.0
199
+ changelog_uri: https://github.com/rubyzip/rubyzip/blob/v3.6.0/Changelog.md
200
+ documentation_uri: https://www.rubydoc.info/gems/rubyzip/3.6.0
201
+ source_code_uri: https://github.com/rubyzip/rubyzip/tree/v3.6.0
202
202
  wiki_uri: https://github.com/rubyzip/rubyzip/wiki
203
203
  rubygems_mfa_required: 'true'
204
204
  rdoc_options: []