rubyzip 3.4.1 → 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 +4 -4
- data/Changelog.md +18 -0
- data/README.md +21 -2
- data/lib/zip/crypto/aes_encryption.rb +5 -2
- data/lib/zip/dos_time.rb +19 -1
- data/lib/zip/entry.rb +3 -2
- data/lib/zip/extra_field/old_unix.rb +2 -2
- data/lib/zip/extra_field/unix.rb +2 -2
- data/lib/zip/extra_field/zip64.rb +2 -2
- data/lib/zip/ioextras.rb +5 -2
- data/lib/zip/output_stream.rb +7 -1
- data/lib/zip/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ad461af594aaafc83f2a9af47a7e72681431835864534c174970e2245748764
|
|
4
|
+
data.tar.gz: 6c5bd535a0b049a606bd64ca90106e633c385926d91c32ca3db72314d2b031f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecd014dee5b905fe5a85af4273e564a0abbdb9c75409a489363352999b2298bfa6baf311c4722c022ddd87807e402d2b9b03f54ec2c110a4cf8c882ed916d301
|
|
7
|
+
data.tar.gz: 7711a4b6bd467e46d020b9d36b58ad726c0ff312d2247e49c9030cbdfb53d206dd5e16ddbb265f34f3f9802c728de06517926de352db7fac8f43ceafd3a3f496
|
data/Changelog.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
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
|
+
|
|
14
|
+
# 3.5.0 (2026-08-18)
|
|
15
|
+
|
|
16
|
+
- Fix the link to Ruby doc in README to the latest version. [#670](https://github.com/rubyzip/rubyzip/pull/670)
|
|
17
|
+
- Support passing decrypter to encrypted entry via get_input_stream. [#667](https://github.com/rubyzip/rubyzip/pull/667)
|
|
18
|
+
|
|
1
19
|
# 3.4.1 (2026-06-27)
|
|
2
20
|
|
|
3
21
|
- Fixed `DecryptedIo` to only perform integrity once. [#665](https://github.com/rubyzip/rubyzip/pull/665)
|
data/README.md
CHANGED
|
@@ -201,7 +201,7 @@ On Posix file systems the default file permissions applied to a new archive
|
|
|
201
201
|
are (0666 - umask), which mimics the behavior of standard tools such as `touch`.
|
|
202
202
|
|
|
203
203
|
On Windows the default file permissions are set to 0644 as suggested by the
|
|
204
|
-
[Ruby File documentation](
|
|
204
|
+
[Ruby File documentation](https://docs.ruby-lang.org/en/master/File.html#class-file-file-permissions).
|
|
205
205
|
|
|
206
206
|
When modifying a zip archive the file permissions of the archive are preserved.
|
|
207
207
|
|
|
@@ -301,6 +301,25 @@ Zip::InputStream.open(buffer, decrypter: dec) do |input|
|
|
|
301
301
|
end
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
+
#### Passing a decrypter to an individual `Entry`
|
|
305
|
+
|
|
306
|
+
You can also decrypt an `Entry` by passing a decrypter into `Zip::Entry#get_input_stream`. This allows you to decrypt files from a Zip file with different passwords.
|
|
307
|
+
|
|
308
|
+
```ruby
|
|
309
|
+
Zip::File.open('aes-encrypted-file.zip') do |zip|
|
|
310
|
+
entries = [['file1.txt', 'password1'], ['file2.txt', 'password2']]
|
|
311
|
+
|
|
312
|
+
entries.each do |entry_name, password|
|
|
313
|
+
entry = zip.find_entry(entry_name)
|
|
314
|
+
dec = Zip::AESDecrypter.new(password, Zip::AESEncryption::STRENGTH_256_BIT)
|
|
315
|
+
zis = entry.get_input_stream(decrypter: dec)
|
|
316
|
+
|
|
317
|
+
puts "Contents of '#{entry.name}':"
|
|
318
|
+
puts zis.read
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
```
|
|
322
|
+
|
|
304
323
|
_This is an evolving feature and the interface for encryption may change in future versions._
|
|
305
324
|
|
|
306
325
|
## Known issues
|
|
@@ -348,7 +367,7 @@ Zip.continue_on_exists_proc = true
|
|
|
348
367
|
|
|
349
368
|
### Non-ASCII Names
|
|
350
369
|
|
|
351
|
-
|
|
370
|
+
To store non-English filenames as UTF-8 (decoded correctly by Windows 7 or later and other modern tools), set this option:
|
|
352
371
|
|
|
353
372
|
```ruby
|
|
354
373
|
Zip.unicode_names = true
|
|
@@ -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 -
|
|
54
|
+
((year - DOS_EPOCH_YEAR) << 9)
|
|
37
55
|
end
|
|
38
56
|
|
|
39
57
|
# Deprecated. Remove for version 4.
|
data/lib/zip/entry.rb
CHANGED
|
@@ -638,8 +638,9 @@ module Zip
|
|
|
638
638
|
end
|
|
639
639
|
|
|
640
640
|
# Returns an IO like object for the given ZipEntry.
|
|
641
|
+
# Optional decrypter can be provided for an encrypted entry
|
|
641
642
|
# Warning: may behave weird with symlinks.
|
|
642
|
-
def get_input_stream(&block)
|
|
643
|
+
def get_input_stream(decrypter: nil, &block)
|
|
643
644
|
if ftype == :directory
|
|
644
645
|
yield ::Zip::NullInputStream if block
|
|
645
646
|
::Zip::NullInputStream
|
|
@@ -656,7 +657,7 @@ module Zip
|
|
|
656
657
|
raise "unknown @file_type #{ftype}"
|
|
657
658
|
end
|
|
658
659
|
else
|
|
659
|
-
zis = ::Zip::InputStream.new(@zipfile, offset: local_header_offset)
|
|
660
|
+
zis = ::Zip::InputStream.new(@zipfile, offset: local_header_offset, decrypter: decrypter)
|
|
660
661
|
zis.instance_variable_set(:@complete_entry, self)
|
|
661
662
|
zis.get_next_entry
|
|
662
663
|
if block
|
data/lib/zip/extra_field/unix.rb
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
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
|
data/lib/zip/output_stream.rb
CHANGED
|
@@ -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
|
-
|
|
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
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.
|
|
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.
|
|
200
|
-
documentation_uri: https://www.rubydoc.info/gems/rubyzip/3.
|
|
201
|
-
source_code_uri: https://github.com/rubyzip/rubyzip/tree/v3.
|
|
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: []
|
|
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
215
215
|
- !ruby/object:Gem::Version
|
|
216
216
|
version: '0'
|
|
217
217
|
requirements: []
|
|
218
|
-
rubygems_version:
|
|
218
|
+
rubygems_version: 4.0.17
|
|
219
219
|
specification_version: 4
|
|
220
220
|
summary: rubyzip is a ruby module for reading and writing zip files
|
|
221
221
|
test_files: []
|