zip_tricks 4.8.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8147080f700510b88cb5e807e61ac71caf94e4b35af7a13162f3fcb0557b221
4
- data.tar.gz: 507c345c51f13b2874577497359f49179447b494eacf55f81c6a0b182feeb97a
3
+ metadata.gz: 327b846ccfc7d19442d21e145a2f767da91f0547381afe52be27db6709dee4a4
4
+ data.tar.gz: 4d80718a715063f1cebad32471ab83e77d38a805f3ceed82793b922d0d3a877f
5
5
  SHA512:
6
- metadata.gz: 328483359ec8a1ced39c3cdc4b853d0fadda7a2c66e1d36e0babc3e701648e57b212b85b5adf6cc24fc92d63eff28889216b11438252f8d1e32d9bdfbb1acaab
7
- data.tar.gz: 99d3e5e9a31ab39ae1bbf39128a086373eadb29a44dee76fc4674eb73ad96ed9c190ca50d9d7227b16f6421d01b2603026386d0e16260eec33f417fd68f85e58
6
+ metadata.gz: 982bc310eb658d67262c28efb043f1ddd3957db197ef1bcbe9108f3572431211069843221d36cf9b28231617d899249ad06be5b9c756189e8f0d383b168a340f
7
+ data.tar.gz: 40fdde09881e02b5a816dae826554e14d76fb26a1bcf09cfcd053450668b34e2d3c63dc5bbf84417b6bdc44f021a35d38fdabd08d9ace5aabe1ff6c335b65e49
@@ -1,17 +1,11 @@
1
- ## 4.8.3
2
-
3
- * Fix a leak of 1 zlib deflater object per deflated file when writing out compressed files with data descriptors. The deflater
4
- needs to be closed explicitly, which we weren't previously doing.
5
-
6
- ## 4.8.2
7
-
8
- * Fix extended timestamp timestamp value encoding. Previously we would use an incorrect encoding for the timestamp value, which would output correct but nonsensical timestamps. The pack specifier is now changed to output the correct value.
9
-
10
- ## 4.8.1
11
-
12
- * Fix extended timestamp extra field output. The first bit of the flag would be set instead of the last bit of
13
- the flag, which made it impossible for Rubyzip to read the timestamp of the entry - and it would also make
14
- the extra field useless for most reading applications.
1
+ ## 5.0.0
2
+
3
+ * Disable automatic filename deduplication by default, because it does not play nice with file/directory
4
+ clobbering. The option can still be enabled by passing `auto_rename_duplicate_filenames: true` to the Streamer
5
+ and all modules that use it
6
+ * Adopt [Hippocratic license v. 1.2](https://firstdonoharm.dev/version/1/2/license.html)
7
+ Note that this might make the license conditions unacceptable for your project. If that is the case,
8
+ you can use the 4.x branch of the library which stays under the original, exact MIT license.
15
9
 
16
10
  ## 4.8.0
17
11
 
@@ -8,8 +8,28 @@ distribute, sublicense, and/or sell copies of the Software, and to
8
8
  permit persons to whom the Software is furnished to do so, subject to
9
9
  the following conditions:
10
10
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
11
+ * The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ * No Harm: The software may not be used by anyone for systems or
15
+ activities that actively and knowingly endanger, harm, or otherwise
16
+ threaten the physical, mental, economic, or general well-being of
17
+ other individuals or groups, in violation of the United Nations
18
+ Universal Declaration of Human Rights
19
+ (https://www.un.org/en/universal-declaration-human-rights/).
20
+
21
+ * Services: If the Software is used to provide a service to others, the
22
+ licensee shall, as a condition of use, require those others not to use
23
+ the service in any way that violates the No Harm clause above.
24
+
25
+ * Enforceability: If any portion or provision of this License shall to
26
+ any extent be declared illegal or unenforceable by a court of
27
+ competent jurisdiction, then the remainder of this License, or the
28
+ application of such portion or provision in circumstances other than
29
+ those as to which it is so declared illegal or unenforceable, shall
30
+ not be affected thereby, and each portion and provision of this
31
+ Agreement shall be valid and enforceable to the fullest extent
32
+ permitted by law.
13
33
 
14
34
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
35
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@@ -18,3 +38,7 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
38
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
39
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
40
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41
+
42
+ This Hippocratic License is an Ethical Source license
43
+ (https://ethicalsource.dev) derived from the MIT License, amended to
44
+ limit the impact of the unethical use of open source software.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # zip_tricks
2
2
 
3
- [![Build Status](https://travis-ci.org/WeTransfer/zip_tricks.svg?branch=backports-v4)](https://travis-ci.org/WeTransfer/zip_tricks)
3
+ [![Build Status](https://travis-ci.org/WeTransfer/zip_tricks.svg?branch=master)](https://travis-ci.org/WeTransfer/zip_tricks)
4
+ [![Gem Version](https://badge.fury.io/rb/zip_tricks.svg)](https://badge.fury.io/rb/zip_tricks)
4
5
 
5
6
  Allows streaming, non-rewinding ZIP file output from Ruby.
6
7
 
@@ -177,4 +178,5 @@ that have not been formally verified (ours hasn't been).
177
178
 
178
179
  ## Copyright
179
180
 
180
- Copyright (c) 2019 WeTransfer. See LICENSE.txt for further details.
181
+ Copyright (c) 2019 WeTransfer. `zip_tricks` is distributed under the conditions of the [Hippocratic License](https://firstdonoharm.dev/version/1/2/license.html)
182
+ - See LICENSE.txt for further details.
@@ -141,11 +141,9 @@ class ZipTricks::Streamer
141
141
  # @param writer[ZipTricks::ZipWriter] the object to be used as the writer.
142
142
  # Defaults to an instance of ZipTricks::ZipWriter, normally you won't need to override it
143
143
  # @param auto_rename_duplicate_filenames[Boolean] whether duplicate filenames, when encountered,
144
- # should be suffixed with (1), (2) etc. Default value is `true` since it
145
- # used to be the default behavior.
146
- #
147
- # **DEPRECATION NOTICE** In ZipTricks version 5 `auto_rename_duplicate_filenames` will default to `false`
148
- def initialize(stream, writer: create_writer, auto_rename_duplicate_filenames: true)
144
+ # should be suffixed with (1), (2) etc. Default value is `false` - if
145
+ # dupliate names are used an exception will be raised
146
+ def initialize(stream, writer: create_writer, auto_rename_duplicate_filenames: false)
149
147
  raise InvalidOutput, 'The stream must respond to #<<' unless stream.respond_to?(:<<)
150
148
 
151
149
  @dedupe_filenames = auto_rename_duplicate_filenames
@@ -50,8 +50,6 @@ class ZipTricks::Streamer::DeflatedWriter
50
50
  def finish
51
51
  @compressed_io << @deflater.finish until @deflater.finished?
52
52
  {crc32: @crc.to_i, compressed_size: @compressed_io.tell, uncompressed_size: @uncompressed_size}
53
- ensure
54
- @deflater.close
55
53
  end
56
54
 
57
55
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZipTricks
4
- VERSION = '4.8.3'
4
+ VERSION = '5.0.0'
5
5
  end
@@ -57,7 +57,7 @@ class ZipTricks::ZipWriter
57
57
  C_UINT2 = 'v' # Encode a 2-byte unsigned little-endian uint
58
58
  C_UINT8 = 'Q<' # Encode an 8-byte unsigned little-endian uint
59
59
  C_CHAR = 'C' # For bit-encoded strings
60
- C_INT4 = 'l<' # Encode a 4-byte signed little-endian int
60
+ C_INT4 = 'N' # Encode a 4-byte signed little-endian int
61
61
 
62
62
  private_constant :FOUR_BYTE_MAX_UINT,
63
63
  :TWO_BYTE_MAX_UINT,
@@ -118,7 +118,7 @@ class ZipTricks::ZipWriter
118
118
  if requires_zip64
119
119
  extra_fields << zip_64_extra_for_local_file_header(compressed_size: compressed_size, uncompressed_size: uncompressed_size)
120
120
  end
121
- extra_fields << timestamp_extra_for_local_file_header(mtime)
121
+ extra_fields << timestamp_extra(mtime)
122
122
 
123
123
  io << [extra_fields.size].pack(C_UINT2) # extra field length 2 bytes
124
124
 
@@ -182,7 +182,7 @@ class ZipTricks::ZipWriter
182
182
  compressed_size: compressed_size,
183
183
  uncompressed_size: uncompressed_size)
184
184
  end
185
- extra_fields << timestamp_extra_for_central_directory_entry(mtime)
185
+ extra_fields << timestamp_extra(mtime)
186
186
 
187
187
  io << [extra_fields.size].pack(C_UINT2) # extra field length 2 bytes
188
188
 
@@ -345,14 +345,12 @@ class ZipTricks::ZipWriter
345
345
  pack_array(data_and_packspecs)
346
346
  end
347
347
 
348
- # Writes the extended timestamp information field for local headers.
349
- #
350
- # The spec defines 2
348
+ # Writes the extended timestamp information field. The spec defines 2
351
349
  # different formats - the one for the local file header can also accomodate the
352
350
  # atime and ctime, whereas the one for the central directory can only take
353
351
  # the mtime - and refers the reader to the local header extra to obtain the
354
352
  # remaining times
355
- def timestamp_extra_for_local_file_header(mtime)
353
+ def timestamp_extra(mtime)
356
354
  # Local-header version:
357
355
  #
358
356
  # Value Size Description
@@ -380,21 +378,16 @@ class ZipTricks::ZipWriter
380
378
  # bit 1 if set, access time is present
381
379
  # bit 2 if set, creation time is present
382
380
  # bits 3-7 reserved for additional timestamps; not set
383
- flags = 0b00000001 # Set the lowest bit only, to indicate that only mtime is present
381
+ flags = 0b10000000 # Set bit 1 only to indicate only mtime is present
384
382
  data_and_packspecs = [
385
383
  0x5455, C_UINT2, # tag for this extra block type ("UT")
386
- (1 + 4), C_UINT2, # the size of this block (1 byte used for the Flag + 3 longs used for the timestamp)
384
+ (1 + 4), C_UINT2, # the size of this block (1 byte used for the Flag + 1 long used for the timestamp)
387
385
  flags, C_CHAR, # encode a single byte
388
- mtime.utc.to_i, C_INT4, # Use a signed int, not the unsigned one used by the rest of the ZIP spec.
386
+ mtime.utc.to_i, C_INT4, # Use a signed long, not the unsigned one used by the rest of the ZIP spec.
389
387
  ]
390
- # The atime and ctime can be omitted if not present
391
388
  pack_array(data_and_packspecs)
392
389
  end
393
390
 
394
- # Since we do not supply atime or ctime, the contents of the two extra fields (central dir and local header)
395
- # is exactly the same, so we can use a method alias.
396
- alias_method :timestamp_extra_for_central_directory_entry, :timestamp_extra_for_local_file_header
397
-
398
391
  # Writes the Zip64 extra field for the central directory header.It differs from the extra used in the local file header because it
399
392
  # also contains the location of the local file header in the ZIP as an 8-byte int.
400
393
  #
@@ -5,9 +5,10 @@ require 'zip_tricks/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'zip_tricks'
7
7
  spec.version = ZipTricks::VERSION
8
- spec.authors = ['Julik Tarkhanov']
8
+ spec.authors = ['Julik Tarkhanov', 'Noah Berman', 'Dmitry Tymchuk', 'David Bosveld']
9
9
  spec.email = ['me@julik.nl']
10
10
 
11
+ spec.licenses = ['MIT (Hippocratic)']
11
12
  spec.summary = 'Stream out ZIP files from Ruby'
12
13
  spec.description = 'Stream out ZIP files from Ruby'
13
14
  spec.homepage = 'http://github.com/wetransfer/zip_tricks'
metadata CHANGED
@@ -1,14 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zip_tricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.3
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
+ - Noah Berman
9
+ - Dmitry Tymchuk
10
+ - David Bosveld
8
11
  autorequire:
9
12
  bindir: exe
10
13
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
14
+ date: 2019-11-01 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
17
  name: bundler
@@ -256,7 +259,8 @@ files:
256
259
  - qa/test-report.txt
257
260
  - zip_tricks.gemspec
258
261
  homepage: http://github.com/wetransfer/zip_tricks
259
- licenses: []
262
+ licenses:
263
+ - MIT (Hippocratic)
260
264
  metadata:
261
265
  allowed_push_host: https://rubygems.org
262
266
  post_install_message:
@@ -274,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
278
  - !ruby/object:Gem::Version
275
279
  version: '0'
276
280
  requirements: []
277
- rubygems_version: 3.1.2
281
+ rubygems_version: 3.0.6
278
282
  signing_key:
279
283
  specification_version: 4
280
284
  summary: Stream out ZIP files from Ruby