rubyzip 2.4.rc1 → 3.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +368 -0
- data/README.md +112 -37
- data/Rakefile +11 -7
- data/lib/zip/central_directory.rb +164 -118
- data/lib/zip/compressor.rb +3 -1
- data/lib/zip/constants.rb +25 -21
- data/lib/zip/crypto/decrypted_io.rb +3 -1
- data/lib/zip/crypto/encryption.rb +4 -2
- data/lib/zip/crypto/null_encryption.rb +5 -3
- data/lib/zip/crypto/traditional_encryption.rb +5 -3
- data/lib/zip/decompressor.rb +4 -3
- data/lib/zip/deflater.rb +10 -8
- data/lib/zip/dirtyable.rb +32 -0
- data/lib/zip/dos_time.rb +32 -3
- data/lib/zip/entry.rb +263 -199
- data/lib/zip/entry_set.rb +9 -7
- data/lib/zip/errors.rb +115 -16
- data/lib/zip/extra_field/generic.rb +3 -10
- data/lib/zip/extra_field/ntfs.rb +4 -2
- data/lib/zip/extra_field/old_unix.rb +3 -1
- data/lib/zip/extra_field/universal_time.rb +3 -1
- data/lib/zip/extra_field/unix.rb +5 -3
- data/lib/zip/extra_field/unknown.rb +33 -0
- data/lib/zip/extra_field/zip64.rb +12 -5
- data/lib/zip/extra_field.rb +15 -21
- data/lib/zip/file.rb +143 -264
- data/lib/zip/file_split.rb +97 -0
- data/lib/zip/filesystem/dir.rb +86 -0
- data/lib/zip/filesystem/directory_iterator.rb +48 -0
- data/lib/zip/filesystem/file.rb +262 -0
- data/lib/zip/filesystem/file_stat.rb +110 -0
- data/lib/zip/filesystem/zip_file_name_mapper.rb +81 -0
- data/lib/zip/filesystem.rb +26 -595
- data/lib/zip/inflater.rb +7 -5
- data/lib/zip/input_stream.rb +44 -39
- data/lib/zip/ioextras/abstract_input_stream.rb +14 -9
- data/lib/zip/ioextras/abstract_output_stream.rb +5 -3
- data/lib/zip/ioextras.rb +6 -6
- data/lib/zip/null_compressor.rb +3 -1
- data/lib/zip/null_decompressor.rb +3 -1
- data/lib/zip/null_input_stream.rb +3 -1
- data/lib/zip/output_stream.rb +47 -48
- data/lib/zip/pass_thru_compressor.rb +3 -1
- data/lib/zip/pass_thru_decompressor.rb +4 -2
- data/lib/zip/streamable_directory.rb +3 -1
- data/lib/zip/streamable_stream.rb +3 -0
- data/lib/zip/version.rb +3 -1
- data/lib/zip.rb +15 -16
- data/rubyzip.gemspec +38 -0
- data/samples/example.rb +8 -3
- data/samples/example_filesystem.rb +2 -1
- data/samples/example_recursive.rb +3 -1
- data/samples/gtk_ruby_zip.rb +4 -2
- data/samples/qtzip.rb +6 -5
- data/samples/write_simple.rb +1 -0
- data/samples/zipfind.rb +1 -0
- metadata +81 -46
- data/TODO +0 -15
- data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd95bfed4ea9c320051f039341277893bedc591147c093a4c527082b81eb6ae3
|
4
|
+
data.tar.gz: ea955185220e2d566bb8c843bd76dd2b076ca1b4353f3d1c1c5910522a2e3d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74dc66a56c1b5e899ba2d683dd4f147be5f301f1d51d86d5d9f027c4c9a74beb48135aaec72e304dd9b8ff92d4f0f2f429d4ab0e0eb5b19c9322bdcf5b66ddea
|
7
|
+
data.tar.gz: 0ad96c3aa4ab42648abdfa8e60d7360a17bc0543d6116a70bd4679f7a9b5da57c1f1d3580bb5e1d7b9d9c8a87b76e084a8f759c4bfacf99e6dca8580d85bf2a7
|
data/Changelog.md
ADDED
@@ -0,0 +1,368 @@
|
|
1
|
+
# 3.0.0 (Next)
|
2
|
+
|
3
|
+
- Don't silently alter zip files opened with `Zip::sort_entries`. [#329](https://github.com/rubyzip/rubyzip/issues/329)
|
4
|
+
- Use named parameters for optional arguments in the public API.
|
5
|
+
- Raise an error if entry names exceed 65,535 characters. [#247](https://github.com/rubyzip/rubyzip/issues/247)
|
6
|
+
- Remove the `ZipXError` v1 legacy classes.
|
7
|
+
- Raise an error on reading a split archive with `InputStream`. [#349](https://github.com/rubyzip/rubyzip/issues/349)
|
8
|
+
- Ensure `InputStream` raises `GPFBit3Error` for OSX Archive files. [#493](https://github.com/rubyzip/rubyzip/issues/493)
|
9
|
+
- Improve documentation and error messages for `InputStream`. [#196](https://github.com/rubyzip/rubyzip/issues/196)
|
10
|
+
- Fix zip file-level comment is not read from zip64 files. [#492](https://github.com/rubyzip/rubyzip/issues/492)
|
11
|
+
- Fix `Zip::OutputStream.write_buffer` doesn't work with Tempfiles. [#265](https://github.com/rubyzip/rubyzip/issues/265)
|
12
|
+
- Reinstate normalising pathname separators to /. [#487](https://github.com/rubyzip/rubyzip/pull/487)
|
13
|
+
- Fix restore options consistency. [#486](https://github.com/rubyzip/rubyzip/pull/486)
|
14
|
+
- View and/or preserve original date created, date modified? (Windows). [#336](https://github.com/rubyzip/rubyzip/issues/336)
|
15
|
+
- Fix frozen string literal error. [#475](https://github.com/rubyzip/rubyzip/pull/475)
|
16
|
+
- Set the default `Entry` time to the file's mtime on Windows. [#465](https://github.com/rubyzip/rubyzip/issues/465)
|
17
|
+
- Ensure that `Entry#time=` sets times as `DOSTime` objects. [#481](https://github.com/rubyzip/rubyzip/issues/481)
|
18
|
+
- Replace and deprecate `Zip::DOSTime#dos_equals`. [#464](https://github.com/rubyzip/rubyzip/pull/464)
|
19
|
+
- Fix loading extra fields. [#459](https://github.com/rubyzip/rubyzip/pull/459)
|
20
|
+
- Set compression level on a per-zipfile basis. [#448](https://github.com/rubyzip/rubyzip/pull/448)
|
21
|
+
- Fix input stream partial read error. [#462](https://github.com/rubyzip/rubyzip/pull/462)
|
22
|
+
- Fix zlib deflate buffer growth. [#447](https://github.com/rubyzip/rubyzip/pull/447)
|
23
|
+
|
24
|
+
Tooling/internal:
|
25
|
+
|
26
|
+
- Configure Coveralls to not report a failure on minor decreases of test coverage. [#491](https://github.com/rubyzip/rubyzip/issues/491)
|
27
|
+
- Extract the file splitting code out into its own module.
|
28
|
+
- Refactor, and tidy up, the `Zip::Filesystem` classes for improved maintainability.
|
29
|
+
- Fix Windows tests. [#489](https://github.com/rubyzip/rubyzip/pull/489)
|
30
|
+
- Refactor `assert_forwarded` so it does not need `ObjectSpace._id2ref` or `eval`. [#483](https://github.com/rubyzip/rubyzip/pull/483)
|
31
|
+
- Add GitHub Actions CI infrastructure. [#469](https://github.com/rubyzip/rubyzip/issues/469)
|
32
|
+
- Add Ruby 3.0 to CI. [#474](https://github.com/rubyzip/rubyzip/pull/474)
|
33
|
+
- Fix the compression level tests to compare relative sizes. [#473](https://github.com/rubyzip/rubyzip/pull/473)
|
34
|
+
- Simplify assertions in basic_zip_file_test. [#470](https://github.com/rubyzip/rubyzip/pull/470)
|
35
|
+
- Remove compare_enumerables from test_helper.rb. [#468](https://github.com/rubyzip/rubyzip/pull/468)
|
36
|
+
- Use correct SPDX license identifier. [#458](https://github.com/rubyzip/rubyzip/pull/458)
|
37
|
+
- Enable truffle ruby in Travis CI. [#450](https://github.com/rubyzip/rubyzip/pull/450)
|
38
|
+
- Update rubocop again and run it in CI. [#444](https://github.com/rubyzip/rubyzip/pull/444)
|
39
|
+
- Fix a test that was incorrect on big-endian architectures. [#445](https://github.com/rubyzip/rubyzip/pull/445)
|
40
|
+
|
41
|
+
# 2.3.2 (2021-07-05)
|
42
|
+
|
43
|
+
- A "dummy" release to warn about breaking changes coming in version 3.0. This updated version uses the Gem `post_install_message` instead of printing to `STDERR`.
|
44
|
+
|
45
|
+
# 2.3.1 (2021-07-03)
|
46
|
+
|
47
|
+
- A "dummy" release to warn about breaking changes coming in version 3.0.
|
48
|
+
|
49
|
+
# 2.3.0 (2020-03-14)
|
50
|
+
|
51
|
+
- Fix frozen string literal error [#431](https://github.com/rubyzip/rubyzip/pull/431)
|
52
|
+
- Set `OutputStream.write_buffer`'s buffer to binmode [#439](https://github.com/rubyzip/rubyzip/pull/439)
|
53
|
+
- Upgrade rubocop and fix various linting complaints [#437](https://github.com/rubyzip/rubyzip/pull/437) [#440](https://github.com/rubyzip/rubyzip/pull/440)
|
54
|
+
|
55
|
+
Tooling:
|
56
|
+
|
57
|
+
- Add a `bin/console` script for development [#420](https://github.com/rubyzip/rubyzip/pull/420)
|
58
|
+
- Update rake requirement (development dependency only) to fix a security alert.
|
59
|
+
|
60
|
+
# 2.2.0 (2020-02-01)
|
61
|
+
|
62
|
+
- Add support for decompression plugin gems [#427](https://github.com/rubyzip/rubyzip/pull/427)
|
63
|
+
|
64
|
+
# 2.1.0 (2020-01-25)
|
65
|
+
|
66
|
+
- Fix (at least partially) the `restore_times` and `restore_permissions` options to `Zip::File.new` [#413](https://github.com/rubyzip/rubyzip/pull/413)
|
67
|
+
- Previously, neither option did anything, regardless of what it was set to. We have therefore defaulted them to `false` to preserve the current behavior, for the time being. If you have explicitly set either to `true`, it will now have an effect.
|
68
|
+
- Fix handling of UniversalTime (`mtime`, `atime`, `ctime`) fields. [#421](https://github.com/rubyzip/rubyzip/pull/421)
|
69
|
+
- Previously, `Zip::File` did not pass the options to `Zip::Entry` in some cases. [#423](https://github.com/rubyzip/rubyzip/pull/423)
|
70
|
+
- Note that `restore_times` in this release does nothing on Windows and only restores `mtime`, not `atime` or `ctime`.
|
71
|
+
- Allow `Zip::File.open` to take an options hash like `Zip::File.new` [#418](https://github.com/rubyzip/rubyzip/pull/418)
|
72
|
+
- Always print warnings with `warn`, instead of a mix of `puts` and `warn` [#416](https://github.com/rubyzip/rubyzip/pull/416)
|
73
|
+
- Create temporary files in the system temporary directory instead of the directory of the zip file [#411](https://github.com/rubyzip/rubyzip/pull/411)
|
74
|
+
- Drop unused `tmpdir` requirement [#411](https://github.com/rubyzip/rubyzip/pull/411)
|
75
|
+
|
76
|
+
Tooling
|
77
|
+
|
78
|
+
- Move CI to xenial and include jruby on JDK11 [#419](https://github.com/rubyzip/rubyzip/pull/419/files)
|
79
|
+
|
80
|
+
# 2.0.0 (2019-09-25)
|
81
|
+
|
82
|
+
Security
|
83
|
+
|
84
|
+
- Default the `validate_entry_sizes` option to `true`, so that callers can trust an entry's reported size when using `extract` [#403](https://github.com/rubyzip/rubyzip/pull/403)
|
85
|
+
- This option defaulted to `false` in 1.3.0 for backward compatibility, but it now defaults to `true`. If you are using an older version of ruby and can't yet upgrade to 2.x, you can still use 1.3.0 and set the option to `true`.
|
86
|
+
|
87
|
+
Tooling / Documentation
|
88
|
+
|
89
|
+
- Remove test files from the gem to avoid problems with antivirus detections on the test files [#405](https://github.com/rubyzip/rubyzip/pull/405) / [#384](https://github.com/rubyzip/rubyzip/issues/384)
|
90
|
+
- Drop support for unsupported ruby versions [#406](https://github.com/rubyzip/rubyzip/pull/406)
|
91
|
+
|
92
|
+
# 1.3.0 (2019-09-25)
|
93
|
+
|
94
|
+
Security
|
95
|
+
|
96
|
+
- Add `validate_entry_sizes` option so that callers can trust an entry's reported size when using `extract` [#403](https://github.com/rubyzip/rubyzip/pull/403)
|
97
|
+
- This option defaults to `false` for backward compatibility in this release, but you are strongly encouraged to set it to `true`. It will default to `true` in rubyzip 2.0.
|
98
|
+
|
99
|
+
New Feature
|
100
|
+
|
101
|
+
- Add `add_stored` method to simplify adding entries without compression [#366](https://github.com/rubyzip/rubyzip/pull/366)
|
102
|
+
|
103
|
+
Tooling / Documentation
|
104
|
+
|
105
|
+
- Add more gem metadata links [#402](https://github.com/rubyzip/rubyzip/pull/402)
|
106
|
+
|
107
|
+
# 1.2.4 (2019-09-06)
|
108
|
+
|
109
|
+
- Do not rewrite zip files opened with `open_buffer` that have not changed [#360](https://github.com/rubyzip/rubyzip/pull/360)
|
110
|
+
|
111
|
+
Tooling / Documentation
|
112
|
+
|
113
|
+
- Update `example_recursive.rb` in README [#397](https://github.com/rubyzip/rubyzip/pull/397)
|
114
|
+
- Hold CI at `trusty` for now, automatically pick the latest ruby patch version, use rbx-4 and hold jruby at 9.1 [#399](https://github.com/rubyzip/rubyzip/pull/399)
|
115
|
+
|
116
|
+
# 1.2.3
|
117
|
+
|
118
|
+
- Allow tilde in zip entry names [#391](https://github.com/rubyzip/rubyzip/pull/391) (fixes regression in 1.2.2 from [#376](https://github.com/rubyzip/rubyzip/pull/376))
|
119
|
+
- Support frozen string literals in more files [#390](https://github.com/rubyzip/rubyzip/pull/390)
|
120
|
+
- Require `pathname` explicitly [#388](https://github.com/rubyzip/rubyzip/pull/388) (fixes regression in 1.2.2 from [#376](https://github.com/rubyzip/rubyzip/pull/376))
|
121
|
+
|
122
|
+
Tooling / Documentation:
|
123
|
+
|
124
|
+
- CI updates [#392](https://github.com/rubyzip/rubyzip/pull/392), [#394](https://github.com/rubyzip/rubyzip/pull/394)
|
125
|
+
- Bump supported ruby versions and add 2.6
|
126
|
+
- JRuby failures are no longer ignored (reverts [#375](https://github.com/rubyzip/rubyzip/pull/375) / part of [#371](https://github.com/rubyzip/rubyzip/pull/371))
|
127
|
+
- Add changelog entry that was missing for last release [#387](https://github.com/rubyzip/rubyzip/pull/387)
|
128
|
+
- Comment cleanup [#385](https://github.com/rubyzip/rubyzip/pull/385)
|
129
|
+
|
130
|
+
# 1.2.2
|
131
|
+
|
132
|
+
NB: This release drops support for extracting symlinks, because there was no clear way to support this securely. See https://github.com/rubyzip/rubyzip/pull/376#issue-210954555 for details.
|
133
|
+
|
134
|
+
- Fix CVE-2018-1000544 [#376](https://github.com/rubyzip/rubyzip/pull/376) / [#371](https://github.com/rubyzip/rubyzip/pull/371)
|
135
|
+
- Fix NoMethodError: undefined method `glob' [#363](https://github.com/rubyzip/rubyzip/pull/363)
|
136
|
+
- Fix handling of stored files (i.e. files not using compression) with general purpose bit 3 set [#358](https://github.com/rubyzip/rubyzip/pull/358)
|
137
|
+
- Fix `close` on StringIO-backed zip file [#353](https://github.com/rubyzip/rubyzip/pull/353)
|
138
|
+
- Add `Zip.force_entry_names_encoding` option [#340](https://github.com/rubyzip/rubyzip/pull/340)
|
139
|
+
- Update rubocop, apply auto-fixes, and fix regressions caused by said auto-fixes [#332](https://github.com/rubyzip/rubyzip/pull/332), [#355](https://github.com/rubyzip/rubyzip/pull/355)
|
140
|
+
- Save temporary files to temporary directory (rather than current directory) [#325](https://github.com/rubyzip/rubyzip/pull/325)
|
141
|
+
|
142
|
+
Tooling / Documentation:
|
143
|
+
|
144
|
+
- Turn off all terminal output in all tests [#361](https://github.com/rubyzip/rubyzip/pull/361)
|
145
|
+
- Several CI updates [#346](https://github.com/rubyzip/rubyzip/pull/346), [#347](https://github.com/rubyzip/rubyzip/pull/347), [#350](https://github.com/rubyzip/rubyzip/pull/350), [#352](https://github.com/rubyzip/rubyzip/pull/352)
|
146
|
+
- Several README improvements [#345](https://github.com/rubyzip/rubyzip/pull/345), [#326](https://github.com/rubyzip/rubyzip/pull/326), [#321](https://github.com/rubyzip/rubyzip/pull/321)
|
147
|
+
|
148
|
+
# 1.2.1
|
149
|
+
|
150
|
+
- Add accessor to @internal_file_attributes #304
|
151
|
+
- Extended globbing #303
|
152
|
+
- README updates #283, #289
|
153
|
+
- Cleanup after tests #298, #306
|
154
|
+
- Fix permissions on new zip files #294, #300
|
155
|
+
- Fix examples #297
|
156
|
+
- Support cp932 encoding #308
|
157
|
+
- Fix Directory traversal vulnerability #315
|
158
|
+
- Allow open_buffer to work without a given block #314
|
159
|
+
|
160
|
+
# 1.2.0
|
161
|
+
|
162
|
+
- Don't enable JRuby objectspace #252
|
163
|
+
- Fixes an exception thrown when decoding some weird .zip files #248
|
164
|
+
- Use duck typing with IO methods #244
|
165
|
+
- Added error for empty (zero bit) zip file #242
|
166
|
+
- Accept StringIO in Zip.open_buffer #238
|
167
|
+
- Do something more expected with new file permissions #237
|
168
|
+
- Case insensitivity option for #find_entry #222
|
169
|
+
- Fixes in documentation and examples
|
170
|
+
|
171
|
+
# 1.1.7
|
172
|
+
|
173
|
+
- Fix UTF-8 support for comments
|
174
|
+
- `Zip.sort_entries` working for zip output
|
175
|
+
- Prevent tempfile path from being unlinked by garbage collection
|
176
|
+
- NTFS Extra Field (0x000a) support
|
177
|
+
- Use String#tr instead of String#gsub
|
178
|
+
- Ability to not show warning about incorrect date
|
179
|
+
- Be smarter about handling buffer file modes.
|
180
|
+
- Support for Traditional Encryption (ZipCrypto)
|
181
|
+
|
182
|
+
# 1.1.6
|
183
|
+
|
184
|
+
- Revert "Return created zip file from Zip::File.open when supplied a block"
|
185
|
+
|
186
|
+
# 1.1.5
|
187
|
+
|
188
|
+
- Treat empty file as non-exists (@layerssss)
|
189
|
+
- Revert regression commit
|
190
|
+
- Return created zip file from Zip::File.open when supplied a block (@tpickett66)
|
191
|
+
- Zip::Entry::DEFLATED is forced on every file (@mehmetc)
|
192
|
+
- Add InputStream#ungetc (@zacstewart)
|
193
|
+
- Alias for legacy error names (@orien)
|
194
|
+
|
195
|
+
# 1.1.4
|
196
|
+
|
197
|
+
- Don't send empty string to stream (@mrloop)
|
198
|
+
- Zip::Entry::DEFLATED was forced on every file (@mehmetc)
|
199
|
+
- Alias for legacy error names (@orien)
|
200
|
+
|
201
|
+
# 1.1.3
|
202
|
+
|
203
|
+
- Fix compatibility of ::OutputStream::write_buffer (@orien)
|
204
|
+
- Clean up tempfiles from output stream (@iangreenleaf)
|
205
|
+
|
206
|
+
# 1.1.2
|
207
|
+
|
208
|
+
- Fix compatibility of ::Zip::File.write_buffer
|
209
|
+
|
210
|
+
# 1.1.1
|
211
|
+
|
212
|
+
- Speedup deflater (@loadhigh)
|
213
|
+
- Less Arrays and Strings allocations (@srawlins)
|
214
|
+
- Fix Zip64 writing support (@mrjamesriley)
|
215
|
+
- Fix StringIO support (@simonoff)
|
216
|
+
- Possibility to change default compression level
|
217
|
+
- Make Zip64 write support optional via configuration
|
218
|
+
|
219
|
+
# 1.1.0
|
220
|
+
|
221
|
+
- StringIO Support
|
222
|
+
- Zip64 Support
|
223
|
+
- Better jRuby Support
|
224
|
+
- Order of files in the archive can be sorted
|
225
|
+
- Other small fixes
|
226
|
+
|
227
|
+
# 1.0.0
|
228
|
+
|
229
|
+
- Removed support for Ruby 1.8
|
230
|
+
- Changed the API for gem. Now it can be used without require param in Gemfile.
|
231
|
+
- Added read-only support for Zip64 files.
|
232
|
+
- Added support for setting Unicode file names.
|
233
|
+
|
234
|
+
# 0.9.9
|
235
|
+
|
236
|
+
- Added support for backslashes in zip files (generated by the default Windows zip packer for example) and comment sections with the comment length set to zero even though there is actually a comment.
|
237
|
+
|
238
|
+
# 0.9.8
|
239
|
+
|
240
|
+
- Fixed: "Unitialized constant NullInputStream" error
|
241
|
+
|
242
|
+
# 0.9.5
|
243
|
+
|
244
|
+
- Removed support for loading ruby in zip files (ziprequire.rb).
|
245
|
+
|
246
|
+
# 0.9.4
|
247
|
+
|
248
|
+
- Changed ZipOutputStream.put_next_entry signature (API CHANGE!). Now allows comment, extra field and compression method to be specified.
|
249
|
+
|
250
|
+
# 0.9.3
|
251
|
+
|
252
|
+
- Fixed: Added ZipEntry::name_encoding which retrieves the character encoding of the name and comment of the entry.
|
253
|
+
- Added convenience methods ZipEntry::name_in(enc) and ZipEntry::comment_in(enc) for getting zip entry names and comments in a specified character encoding.
|
254
|
+
|
255
|
+
# 0.9.2
|
256
|
+
|
257
|
+
- Fixed: Renaming an entry failed if the entry's new name was a different length than its old name. (Diego Barros)
|
258
|
+
|
259
|
+
# 0.9.1
|
260
|
+
|
261
|
+
- Added symlink support and support for unix file permissions. Reduced memory usage during decompression.
|
262
|
+
- New methods ZipFile::[follow_symlinks, restore_times, restore_permissions, restore_ownership].
|
263
|
+
- New methods ZipEntry::unix_perms, ZipInputStream::eof?.
|
264
|
+
- Added documentation and test for new ZipFile::extract.
|
265
|
+
- Added some of the API suggestions from sf.net #1281314.
|
266
|
+
- Applied patch for sf.net bug #1446926.
|
267
|
+
- Applied patch for sf.net bug #1459902.
|
268
|
+
- Rework ZipEntry and delegate classes.
|
269
|
+
|
270
|
+
# 0.5.12
|
271
|
+
|
272
|
+
- Fixed problem with writing binary content to a ZipFile in MS Windows.
|
273
|
+
|
274
|
+
# 0.5.11
|
275
|
+
|
276
|
+
- Fixed name clash file method copy_stream from fileutils.rb. Fixed problem with references to constant CHUNK_SIZE.
|
277
|
+
- ZipInputStream/AbstractInputStream read is now buffered like ruby IO's read method, which means that read and gets etc can be mixed. The unbuffered read method has been renamed to sysread.
|
278
|
+
|
279
|
+
# 0.5.10
|
280
|
+
|
281
|
+
- Fixed method name resolution problem with FileUtils::copy_stream and IOExtras::copy_stream.
|
282
|
+
|
283
|
+
# 0.5.9
|
284
|
+
|
285
|
+
- Fixed serious memory consumption issue
|
286
|
+
|
287
|
+
# 0.5.8
|
288
|
+
|
289
|
+
- Fixed install script.
|
290
|
+
|
291
|
+
# 0.5.7
|
292
|
+
|
293
|
+
- install.rb no longer assumes it is being run from the toplevel source dir. Directory structure changed to reflect common ruby library project structure. Migrated from RubyUnit to Test::Unit format. Now uses Rake to build source packages and gems and run unit tests.
|
294
|
+
|
295
|
+
# 0.5.6
|
296
|
+
|
297
|
+
- Fix for FreeBSD 4.9 which returns Errno::EFBIG instead of Errno::EINVAL for some invalid seeks. Fixed 'version needed to extract'-field incorrect in local headers.
|
298
|
+
|
299
|
+
# 0.5.5
|
300
|
+
|
301
|
+
- Fix for a problem with writing zip files that concerns only ruby 1.8.1.
|
302
|
+
|
303
|
+
# 0.5.4
|
304
|
+
|
305
|
+
- Significantly reduced memory footprint when modifying zip files.
|
306
|
+
|
307
|
+
# 0.5.3
|
308
|
+
|
309
|
+
- Added optimization to avoid decompressing and recompressing individual entries when modifying a zip archive.
|
310
|
+
|
311
|
+
# 0.5.2
|
312
|
+
|
313
|
+
- Fixed ZipFile corruption bug in ZipFile class. Added basic unix extra-field support.
|
314
|
+
|
315
|
+
# 0.5.1
|
316
|
+
|
317
|
+
- Fixed ZipFile.get_output_stream bug.
|
318
|
+
|
319
|
+
# 0.5.0
|
320
|
+
|
321
|
+
- Ruby 1.8.0 and ruby-zlib 0.6.0 compatibility
|
322
|
+
- Changed method names from camelCase to rubys underscore style.
|
323
|
+
- Installs to zip/ subdir instead of directly to site_ruby
|
324
|
+
- Added ZipFile.directory and ZipFile.file - each method return an
|
325
|
+
object that can be used like Dir and File only for the contents of the
|
326
|
+
zip file.
|
327
|
+
- Added sample application zipfind which works like Find.find, only
|
328
|
+
Zip::ZipFind.find traverses into zip archives too.
|
329
|
+
- FIX: AbstractInputStream.each_line with non-default separator
|
330
|
+
|
331
|
+
# 0.5.0a
|
332
|
+
|
333
|
+
Source reorganized. Added ziprequire, which can be used to load ruby modules from a zip file, in a fashion similar to jar files in Java. Added gtk_ruby_zip, another sample application. Implemented ZipInputStream.lineno and ZipInputStream.rewind
|
334
|
+
|
335
|
+
Bug fixes:
|
336
|
+
|
337
|
+
- Read and write date and time information correctly for zip entries.
|
338
|
+
- Fixed read() using separate buffer, causing mix of gets/readline/read to cause problems.
|
339
|
+
|
340
|
+
# 0.4.2
|
341
|
+
|
342
|
+
- Performance optimizations. Test suite runs in half the time.
|
343
|
+
|
344
|
+
# 0.4.1
|
345
|
+
|
346
|
+
- Windows compatibility fixes.
|
347
|
+
|
348
|
+
# 0.4.0
|
349
|
+
|
350
|
+
- Zip::ZipFile is now mutable and provides a more convenient way of modifying zip archives than Zip::ZipOutputStream. Operations for adding, extracting, renaming, replacing and removing entries to zip archives are now available.
|
351
|
+
- Runs without warnings with -w switch.
|
352
|
+
- Install script install.rb added.
|
353
|
+
|
354
|
+
# 0.3.1
|
355
|
+
|
356
|
+
- Rudimentary support for writing zip archives.
|
357
|
+
|
358
|
+
# 0.2.2
|
359
|
+
|
360
|
+
- Fixed and extended unit test suite. Updated to work with ruby/zlib 0.5. It doesn't work with earlier versions of ruby/zlib.
|
361
|
+
|
362
|
+
# 0.2.0
|
363
|
+
|
364
|
+
- Class ZipFile added. Where ZipInputStream is used to read the individual entries in a zip file, ZipFile reads the central directory in the zip archive, so you can get to any entry in the zip archive without having to skipping through all the preceeding entries.
|
365
|
+
|
366
|
+
# 0.1.0
|
367
|
+
|
368
|
+
- First working version of ZipInputStream.
|
data/README.md
CHANGED
@@ -2,31 +2,29 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/rubyzip.svg)](http://badge.fury.io/rb/rubyzip)
|
4
4
|
[![Tests](https://github.com/rubyzip/rubyzip/actions/workflows/tests.yml/badge.svg)](https://github.com/rubyzip/rubyzip/actions/workflows/tests.yml)
|
5
|
+
[![Linter](https://github.com/rubyzip/rubyzip/actions/workflows/lint.yml/badge.svg)](https://github.com/rubyzip/rubyzip/actions/workflows/lint.yml)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/rubyzip/rubyzip.svg)](https://codeclimate.com/github/rubyzip/rubyzip)
|
6
7
|
[![Coverage Status](https://img.shields.io/coveralls/rubyzip/rubyzip.svg)](https://coveralls.io/r/rubyzip/rubyzip?branch=master)
|
7
8
|
|
8
9
|
Rubyzip is a ruby library for reading and writing zip files.
|
9
10
|
|
10
|
-
## Important
|
11
|
-
|
12
|
-
Rubyzip 2.4 is intended to be the last release in the 2.x series. Please get ready for version 3.0.
|
11
|
+
## Important notes
|
13
12
|
|
14
13
|
### Updating to version 3.0
|
15
14
|
|
16
|
-
The public API of some classes has been modernized to use named parameters for optional arguments.
|
15
|
+
The public API of some classes has been modernized to use named parameters for optional arguments. Please check your usage of the following Rubyzip classes:
|
17
16
|
* `File`
|
18
17
|
* `Entry`
|
19
18
|
* `InputStream`
|
20
19
|
* `OutputStream`
|
21
|
-
* `DOSTime`
|
22
20
|
|
23
21
|
**Please see [Updating to version 3.x](https://github.com/rubyzip/rubyzip/wiki/Updating-to-version-3.x) in the wiki for details.**
|
24
22
|
|
25
23
|
## Requirements
|
26
24
|
|
27
|
-
Version 3.x requires at least Ruby
|
25
|
+
Version 3.x requires at least Ruby 2.5.
|
28
26
|
|
29
|
-
Version 2.x requires at least Ruby 2.4, and is known to work on Ruby 3.
|
27
|
+
Version 2.x requires at least Ruby 2.4, and is known to work on Ruby 3.1.
|
30
28
|
|
31
29
|
It is not recommended to use any versions of Rubyzip earlier than 2.3 due to security issues.
|
32
30
|
|
@@ -57,7 +55,7 @@ input_filenames = ['image.jpg', 'description.txt', 'stats.csv']
|
|
57
55
|
|
58
56
|
zipfile_name = "/Users/me/Desktop/archive.zip"
|
59
57
|
|
60
|
-
Zip::File.open(zipfile_name,
|
58
|
+
Zip::File.open(zipfile_name, create: true) do |zipfile|
|
61
59
|
input_filenames.each do |filename|
|
62
60
|
# Two arguments:
|
63
61
|
# - The name of the file as it will appear in the archive
|
@@ -96,7 +94,7 @@ class ZipFileGenerator
|
|
96
94
|
def write
|
97
95
|
entries = Dir.entries(@input_dir) - %w[. ..]
|
98
96
|
|
99
|
-
::Zip::File.open(@output_file,
|
97
|
+
::Zip::File.open(@output_file, create: true) do |zipfile|
|
100
98
|
write_entries entries, '', zipfile
|
101
99
|
end
|
102
100
|
end
|
@@ -129,9 +127,9 @@ class ZipFileGenerator
|
|
129
127
|
end
|
130
128
|
```
|
131
129
|
|
132
|
-
### Save zip archive entries
|
130
|
+
### Save zip archive entries sorted by name
|
133
131
|
|
134
|
-
To save zip archives
|
132
|
+
To save zip archives with their entries sorted by name (see below), set `::Zip.sort_entries` to `true`
|
135
133
|
|
136
134
|
```
|
137
135
|
Vegetable/
|
@@ -145,7 +143,7 @@ fruit/mango
|
|
145
143
|
fruit/orange
|
146
144
|
```
|
147
145
|
|
148
|
-
|
146
|
+
Opening an existing zip file with this option set will not change the order of the entries automatically. Altering the zip file - adding an entry, renaming an entry, adding or changing the archive comment, etc - will cause the ordering to be applied when closing the file.
|
149
147
|
|
150
148
|
### Default permissions of zip archives
|
151
149
|
|
@@ -181,28 +179,50 @@ Zip::File.open('foo.zip') do |zip_file|
|
|
181
179
|
end
|
182
180
|
```
|
183
181
|
|
184
|
-
|
182
|
+
### Notes on `Zip::InputStream`
|
183
|
+
|
184
|
+
`Zip::InputStream` can be used for faster reading of zip file content because it does not read the Central directory up front.
|
185
185
|
|
186
|
-
|
186
|
+
There is one exception where it can not work however, and this is if the file does not contain enough information in the local entry headers to extract an entry. This is indicated in an entry by the General Purpose Flag bit 3 being set.
|
187
187
|
|
188
|
-
|
188
|
+
> If bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the header is written. The fields in the local header are filled with zero, and the CRC-32 and size are appended in a 12-byte structure (optionally preceded by a 4-byte signature) immediately after the compressed data.
|
189
189
|
|
190
|
-
|
190
|
+
If `Zip::InputStream` finds such an entry in the zip archive it will raise an exception (`Zip::StreamingError`).
|
191
191
|
|
192
|
-
|
192
|
+
`Zip::InputStream` is not designed to be used for random access in a zip file. When performing any operations on an entry that you are accessing via `Zip::InputStream.get_next_entry` then you should complete any such operations before the next call to `get_next_entry`.
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
zip_stream = Zip::InputStream.new(File.open('file.zip'))
|
196
|
+
|
197
|
+
while entry = zip_stream.get_next_entry
|
198
|
+
# All required operations on `entry` go here.
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
202
|
+
Any attempt to move about in a zip file opened with `Zip::InputStream` could result in the incorrect entry being accessed and/or Zlib buffer errors. If you need random access in a zip file, use `Zip::File`.
|
193
203
|
|
194
204
|
### Password Protection (Experimental)
|
195
205
|
|
196
206
|
Rubyzip supports reading/writing zip files with traditional zip encryption (a.k.a. "ZipCrypto"). AES encryption is not yet supported. It can be used with buffer streams, e.g.:
|
197
207
|
|
198
208
|
```ruby
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
209
|
+
# Writing.
|
210
|
+
enc = Zip::TraditionalEncrypter.new('password')
|
211
|
+
buffer = Zip::OutputStream.write_buffer(encrypter: enc) do |output|
|
212
|
+
output.put_next_entry("my_file.txt")
|
213
|
+
output.write my_data
|
214
|
+
end
|
215
|
+
|
216
|
+
# Reading.
|
217
|
+
dec = Zip::TraditionalDecrypter.new('password')
|
218
|
+
Zip::InputStream.open(buffer, decrypter: dec) do |input|
|
219
|
+
entry = input.get_next_entry
|
220
|
+
puts "Contents of '#{entry.name}':"
|
221
|
+
puts input.read
|
222
|
+
end
|
203
223
|
```
|
204
224
|
|
205
|
-
|
225
|
+
_This is an experimental feature and the interface for encryption may change in future versions._
|
206
226
|
|
207
227
|
## Known issues
|
208
228
|
|
@@ -216,7 +236,7 @@ buffer = Zip::OutputStream.write_buffer do |out|
|
|
216
236
|
unless [DOCUMENT_FILE_PATH, RELS_FILE_PATH].include?(e.name)
|
217
237
|
out.put_next_entry(e.name)
|
218
238
|
out.write e.get_input_stream.read
|
219
|
-
|
239
|
+
end
|
220
240
|
end
|
221
241
|
|
222
242
|
out.put_next_entry(DOCUMENT_FILE_PATH)
|
@@ -296,25 +316,35 @@ Zip.validate_entry_sizes = false
|
|
296
316
|
|
297
317
|
Note that if you use the lower level `Zip::InputStream` interface, `rubyzip` does *not* check the entry `size`s. In this case, the caller is responsible for making sure it does not read more data than expected from the input stream.
|
298
318
|
|
299
|
-
###
|
319
|
+
### Compression level
|
300
320
|
|
301
|
-
|
321
|
+
When adding entries to a zip archive you can set the compression level to trade-off compressed size against compression speed. By default this is set to the same as the underlying Zlib library's default (`Zlib::DEFAULT_COMPRESSION`), which is somewhere in the middle.
|
322
|
+
|
323
|
+
You can configure the default compression level with:
|
302
324
|
|
303
325
|
```ruby
|
304
|
-
Zip.default_compression =
|
326
|
+
Zip.default_compression = X
|
305
327
|
```
|
306
328
|
|
307
|
-
|
329
|
+
Where X is an integer between 0 and 9, inclusive. If this option is set to 0 (`Zlib::NO_COMPRESSION`) then entries will be stored in the zip archive uncompressed. A value of 1 (`Zlib::BEST_SPEED`) gives the fastest compression and 9 (`Zlib::BEST_COMPRESSION`) gives the smallest compressed file size.
|
330
|
+
|
331
|
+
This can also be set for each archive as an option to `Zip::File`:
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
Zip::File.open('foo.zip', create:true, compression_level: 9) do |zip|
|
335
|
+
zip.add ...
|
336
|
+
end
|
337
|
+
```
|
308
338
|
|
309
339
|
### Zip64 Support
|
310
340
|
|
311
|
-
By default, Zip64 support is
|
341
|
+
By default, Zip64 support is enabled for writing. To disable it do this:
|
312
342
|
|
313
343
|
```ruby
|
314
|
-
Zip.write_zip64_support =
|
344
|
+
Zip.write_zip64_support = false
|
315
345
|
```
|
316
346
|
|
317
|
-
_NOTE_: If
|
347
|
+
_NOTE_: If Zip64 write support is enabled then any extractor subsequently used may also require Zip64 support to read from the resultant archive.
|
318
348
|
|
319
349
|
### Block Form
|
320
350
|
|
@@ -329,15 +359,47 @@ You can set multiple settings at the same time by using a block:
|
|
329
359
|
end
|
330
360
|
```
|
331
361
|
|
362
|
+
## Compatibility
|
363
|
+
|
364
|
+
Rubyzip is known to run on a number of platforms and under a number of different Ruby versions.
|
365
|
+
|
366
|
+
### Version 2.3.x
|
367
|
+
|
368
|
+
Rubyzip 2.3 is known to work on MRI 2.4 to 3.1 on Linux and Mac, and JRuby and Truffleruby on Linux. There are known issues with Windows which have been fixed on the development branch. Please [let us know](https://github.com/rubyzip/rubyzip/pulls) if you know Rubyzip 2.3 works on a platform/Ruby combination not listed here, or [raise an issue](https://github.com/rubyzip/rubyzip/issues) if you see a failure where we think it should work.
|
369
|
+
|
370
|
+
### Next (version 3.0.0)
|
371
|
+
|
372
|
+
Please see the table below for what we think the current situation is. Note: an empty cell means "unknown", not "does not work".
|
373
|
+
|
374
|
+
| OS/Ruby | 2.5 | 2.6 | 2.7 | 3.0 | 3.1 | 3.1 +YJIT | Head | Head +YJIT | JRuby 9.3.2.0 | JRuby Head | Truffleruby 21.3.0 | Truffleruby Head |
|
375
|
+
|---------|-----|-----|-----|-----|-----|----------|------|-----------|----------------|------------|--------------------|------------------|
|
376
|
+
|Ubuntu 20.04.3| CI | CI | CI | CI | CI | ci | ci | ci | CI | ci | CI | ci |
|
377
|
+
|Mac OS 11.6.2| CI | x | x | x | x | ci | | ci | x | | x | |
|
378
|
+
|Windows 10| | | x | | | | | | | | | |
|
379
|
+
|Windows Server 2019| CI | | | | | | | | | | | |
|
380
|
+
|
381
|
+
Key: `CI` - tested in CI, should work; `ci` - tested in CI, might fail; `x` - known working; `o` - known failing.
|
382
|
+
|
383
|
+
Please [raise a PR](https://github.com/rubyzip/rubyzip/pulls) if you know Rubyzip works on a platform/Ruby combination not listed here, or [raise an issue](https://github.com/rubyzip/rubyzip/issues) if you see a failure where we think it should work.
|
384
|
+
|
332
385
|
## Developing
|
333
386
|
|
334
|
-
|
387
|
+
Install the dependencies:
|
335
388
|
|
336
|
-
```
|
389
|
+
```shell
|
337
390
|
bundle install
|
391
|
+
```
|
392
|
+
|
393
|
+
Run the tests with `rake`:
|
394
|
+
|
395
|
+
```shell
|
338
396
|
rake
|
339
397
|
```
|
340
398
|
|
399
|
+
Please also run `rubocop` over your changes.
|
400
|
+
|
401
|
+
Our CI runs on [GitHub Actions](https://github.com/rubyzip/rubyzip/actions). Please note that `rubocop` is run as part of the CI configuration and will fail a build if errors are found.
|
402
|
+
|
341
403
|
## Website and Project Home
|
342
404
|
|
343
405
|
http://github.com/rubyzip/rubyzip
|
@@ -346,17 +408,30 @@ http://rdoc.info/github/rubyzip/rubyzip/master/frames
|
|
346
408
|
|
347
409
|
## Authors
|
348
410
|
|
349
|
-
|
411
|
+
See https://github.com/rubyzip/rubyzip/graphs/contributors for a comprehensive list.
|
350
412
|
|
351
|
-
|
413
|
+
### Current maintainers
|
352
414
|
|
353
|
-
|
415
|
+
* Robert Haines (@hainesr)
|
416
|
+
* John Lees-Miller (@jdleesmiller)
|
417
|
+
* Oleksandr Simonov (@simonoff)
|
354
418
|
|
355
|
-
|
419
|
+
### Original author
|
356
420
|
|
357
|
-
|
421
|
+
* Thomas Sondergaard
|
358
422
|
|
359
423
|
## License
|
360
424
|
|
361
425
|
Rubyzip is distributed under the same license as ruby. See
|
362
426
|
http://www.ruby-lang.org/en/LICENSE.txt
|
427
|
+
|
428
|
+
## Research notice
|
429
|
+
Please note that this repository is participating in a study into sustainability
|
430
|
+
of open source projects. Data will be gathered about this repository for
|
431
|
+
approximately the next 12 months, starting from June 2021.
|
432
|
+
|
433
|
+
Data collected will include number of contributors, number of PRs, time taken to
|
434
|
+
close/merge these PRs, and issues closed.
|
435
|
+
|
436
|
+
For more information, please visit
|
437
|
+
[our informational page](https://sustainable-open-science-and-software.github.io/) or download our [participant information sheet](https://sustainable-open-science-and-software.github.io/assets/PIS_sustainable_software.pdf).
|