rubyzip 1.2.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -14
- data/lib/zip.rb +3 -1
- data/lib/zip/entry.rb +12 -0
- data/lib/zip/errors.rb +1 -0
- data/lib/zip/file.rb +7 -0
- data/lib/zip/version.rb +1 -1
- metadata +10 -153
- data/test/basic_zip_file_test.rb +0 -60
- data/test/case_sensitivity_test.rb +0 -69
- data/test/central_directory_entry_test.rb +0 -69
- data/test/central_directory_test.rb +0 -100
- data/test/crypto/null_encryption_test.rb +0 -57
- data/test/crypto/traditional_encryption_test.rb +0 -80
- data/test/data/WarnInvalidDate.zip +0 -0
- data/test/data/file1.txt +0 -46
- data/test/data/file1.txt.deflatedData +0 -0
- data/test/data/file2.txt +0 -1504
- data/test/data/globTest.zip +0 -0
- data/test/data/globTest/foo.txt +0 -0
- data/test/data/globTest/foo/bar/baz/foo.txt +0 -0
- data/test/data/globTest/food.txt +0 -0
- data/test/data/gpbit3stored.zip +0 -0
- data/test/data/mimetype +0 -1
- data/test/data/notzippedruby.rb +0 -7
- data/test/data/ntfs.zip +0 -0
- data/test/data/oddExtraField.zip +0 -0
- data/test/data/path_traversal/Makefile +0 -10
- data/test/data/path_traversal/jwilk/README.md +0 -5
- data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
- data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
- data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
- data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
- data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
- data/test/data/path_traversal/jwilk/relative0.zip +0 -0
- data/test/data/path_traversal/jwilk/relative2.zip +0 -0
- data/test/data/path_traversal/jwilk/symlink.zip +0 -0
- data/test/data/path_traversal/relative1.zip +0 -0
- data/test/data/path_traversal/tilde.zip +0 -0
- data/test/data/path_traversal/tuzovakaoff/README.md +0 -3
- data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
- data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
- data/test/data/rubycode.zip +0 -0
- data/test/data/rubycode2.zip +0 -0
- data/test/data/test.xls +0 -0
- data/test/data/testDirectory.bin +0 -0
- data/test/data/zip64-sample.zip +0 -0
- data/test/data/zipWithDirs.zip +0 -0
- data/test/data/zipWithEncryption.zip +0 -0
- data/test/deflater_test.rb +0 -65
- data/test/encryption_test.rb +0 -42
- data/test/entry_set_test.rb +0 -163
- data/test/entry_test.rb +0 -154
- data/test/errors_test.rb +0 -35
- data/test/extra_field_test.rb +0 -76
- data/test/file_extract_directory_test.rb +0 -54
- data/test/file_extract_test.rb +0 -83
- data/test/file_permissions_test.rb +0 -65
- data/test/file_split_test.rb +0 -57
- data/test/file_test.rb +0 -646
- data/test/filesystem/dir_iterator_test.rb +0 -58
- data/test/filesystem/directory_test.rb +0 -139
- data/test/filesystem/file_mutating_test.rb +0 -87
- data/test/filesystem/file_nonmutating_test.rb +0 -508
- data/test/filesystem/file_stat_test.rb +0 -64
- data/test/gentestfiles.rb +0 -126
- data/test/inflater_test.rb +0 -14
- data/test/input_stream_test.rb +0 -182
- data/test/ioextras/abstract_input_stream_test.rb +0 -102
- data/test/ioextras/abstract_output_stream_test.rb +0 -106
- data/test/ioextras/fake_io_test.rb +0 -18
- data/test/local_entry_test.rb +0 -154
- data/test/output_stream_test.rb +0 -128
- data/test/pass_thru_compressor_test.rb +0 -30
- data/test/pass_thru_decompressor_test.rb +0 -14
- data/test/path_traversal_test.rb +0 -141
- data/test/samples/example_recursive_test.rb +0 -37
- data/test/settings_test.rb +0 -95
- data/test/test_helper.rb +0 -234
- data/test/unicode_file_names_and_comments_test.rb +0 -62
- data/test/zip64_full_test.rb +0 -51
- data/test/zip64_support_test.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e2be8aa3dea85f1e99fa26b5b2530ede874228f35379181d5219eb3864a0e33
|
4
|
+
data.tar.gz: '0985b8cd0b421a0bdf83953ba907ddad52d236948a81a242f322f0f5fa2145a6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c870bef8352ddb4e706a847f66da596fe556938d1b1422c3541f8ab24aa10bbdb6be577cd031853459101e24a4290aa816436834d1cae66dd26238b451f41d15
|
7
|
+
data.tar.gz: bb5c8ca7d286346bfad64a6e1bd637cb8a40a99974bc62fbd76ea1a5ee139d16dcf52a8480cc219e48e311d84046feafab2c497cfbeb0721940a06a5c7a163a2
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ gem 'zip-zip' # will load compatibility for old rubyzip API.
|
|
20
20
|
|
21
21
|
## Requirements
|
22
22
|
|
23
|
-
- Ruby
|
23
|
+
- Ruby 2.4 or greater (for rubyzip 2.0; use 1.x for older rubies)
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
@@ -152,12 +152,15 @@ When modifying a zip archive the file permissions of the archive are preserved.
|
|
152
152
|
### Reading a Zip file
|
153
153
|
|
154
154
|
```ruby
|
155
|
+
MAX_SIZE = 1024**2 # 1MiB (but of course you can increase this)
|
155
156
|
Zip::File.open('foo.zip') do |zip_file|
|
156
157
|
# Handle entries one by one
|
157
158
|
zip_file.each do |entry|
|
158
|
-
# Extract to file/directory/symlink
|
159
159
|
puts "Extracting #{entry.name}"
|
160
|
-
entry.
|
160
|
+
raise 'File too large when extracted' if entry.size > MAX_SIZE
|
161
|
+
|
162
|
+
# Extract to file or directory based on name in the archive
|
163
|
+
entry.extract
|
161
164
|
|
162
165
|
# Read into memory
|
163
166
|
content = entry.get_input_stream.read
|
@@ -165,6 +168,7 @@ Zip::File.open('foo.zip') do |zip_file|
|
|
165
168
|
|
166
169
|
# Find specific entry
|
167
170
|
entry = zip_file.glob('*.csv').first
|
171
|
+
raise 'File too large when extracted' if entry.size > MAX_SIZE
|
168
172
|
puts entry.get_input_stream.read
|
169
173
|
end
|
170
174
|
```
|
@@ -219,6 +223,8 @@ File.open(new_path, "wb") {|f| f.write(buffer.string) }
|
|
219
223
|
|
220
224
|
## Configuration
|
221
225
|
|
226
|
+
### Existing Files
|
227
|
+
|
222
228
|
By default, rubyzip will not overwrite files if they already exist inside of the extracted path. To change this behavior, you may specify a configuration option like so:
|
223
229
|
|
224
230
|
```ruby
|
@@ -233,18 +239,57 @@ Additionally, if you want to configure rubyzip to overwrite existing files while
|
|
233
239
|
Zip.continue_on_exists_proc = true
|
234
240
|
```
|
235
241
|
|
242
|
+
### Non-ASCII Names
|
243
|
+
|
236
244
|
If you want to store non-english names and want to open them on Windows(pre 7) you need to set this option:
|
237
245
|
|
238
246
|
```ruby
|
239
247
|
Zip.unicode_names = true
|
240
248
|
```
|
241
249
|
|
250
|
+
Sometimes file names inside zip contain non-ASCII characters. If you can assume which encoding was used for such names and want to be able to find such entries using `find_entry` then you can force assumed encoding like so:
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
Zip.force_entry_names_encoding = 'UTF-8'
|
254
|
+
```
|
255
|
+
|
256
|
+
Allowed encoding names are the same as accepted by `String#force_encoding`
|
257
|
+
|
258
|
+
### Date Validation
|
259
|
+
|
242
260
|
Some zip files might have an invalid date format, which will raise a warning. You can hide this warning with the following setting:
|
243
261
|
|
244
262
|
```ruby
|
245
263
|
Zip.warn_invalid_date = false
|
246
264
|
```
|
247
265
|
|
266
|
+
### Size Validation
|
267
|
+
|
268
|
+
By default (in rubyzip >= 2.0), rubyzip's `extract` method checks that an entry's reported uncompressed size is not (significantly) smaller than its actual size. This is to help you protect your application against [zip bombs](https://en.wikipedia.org/wiki/Zip_bomb). Before `extract`ing an entry, you should check that its size is in the range you expect. For example, if your application supports processing up to 100 files at once, each up to 10MiB, your zip extraction code might look like:
|
269
|
+
|
270
|
+
```ruby
|
271
|
+
MAX_FILE_SIZE = 10 * 1024**2 # 10MiB
|
272
|
+
MAX_FILES = 100
|
273
|
+
Zip::File.open('foo.zip') do |zip_file|
|
274
|
+
num_files = 0
|
275
|
+
zip_file.each do |entry|
|
276
|
+
num_files += 1 if entry.file?
|
277
|
+
raise 'Too many extracted files' if num_files > MAX_FILES
|
278
|
+
raise 'File too large when extracted' if entry.size > MAX_FILE_SIZE
|
279
|
+
entry.extract
|
280
|
+
end
|
281
|
+
end
|
282
|
+
```
|
283
|
+
|
284
|
+
If you need to extract zip files that report incorrect uncompressed sizes and you really trust them not too be too large, you can disable this setting with
|
285
|
+
```ruby
|
286
|
+
Zip.validate_entry_sizes = false
|
287
|
+
```
|
288
|
+
|
289
|
+
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.
|
290
|
+
|
291
|
+
### Default Compression
|
292
|
+
|
248
293
|
You can set the default compression level like so:
|
249
294
|
|
250
295
|
```ruby
|
@@ -253,13 +298,17 @@ Zip.default_compression = Zlib::DEFAULT_COMPRESSION
|
|
253
298
|
|
254
299
|
It defaults to `Zlib::DEFAULT_COMPRESSION`. Possible values are `Zlib::BEST_COMPRESSION`, `Zlib::DEFAULT_COMPRESSION` and `Zlib::NO_COMPRESSION`
|
255
300
|
|
256
|
-
|
301
|
+
### Zip64 Support
|
302
|
+
|
303
|
+
By default, Zip64 support is disabled for writing. To enable it do this:
|
257
304
|
|
258
305
|
```ruby
|
259
|
-
Zip.
|
306
|
+
Zip.write_zip64_support = true
|
260
307
|
```
|
261
308
|
|
262
|
-
|
309
|
+
_NOTE_: If you will enable Zip64 writing then you will need zip extractor with Zip64 support to extract archive.
|
310
|
+
|
311
|
+
### Block Form
|
263
312
|
|
264
313
|
You can set multiple settings at the same time by using a block:
|
265
314
|
|
@@ -272,14 +321,6 @@ You can set multiple settings at the same time by using a block:
|
|
272
321
|
end
|
273
322
|
```
|
274
323
|
|
275
|
-
By default, Zip64 support is disabled for writing. To enable it do this:
|
276
|
-
|
277
|
-
```ruby
|
278
|
-
Zip.write_zip64_support = true
|
279
|
-
```
|
280
|
-
|
281
|
-
_NOTE_: If you will enable Zip64 writing then you will need zip extractor with Zip64 support to extract archive.
|
282
|
-
|
283
324
|
## Developing
|
284
325
|
|
285
326
|
To run the test you need to do this:
|
data/lib/zip.rb
CHANGED
@@ -42,7 +42,8 @@ module Zip
|
|
42
42
|
:write_zip64_support,
|
43
43
|
:warn_invalid_date,
|
44
44
|
:case_insensitive_match,
|
45
|
-
:force_entry_names_encoding
|
45
|
+
:force_entry_names_encoding,
|
46
|
+
:validate_entry_sizes
|
46
47
|
|
47
48
|
def reset!
|
48
49
|
@_ran_once = false
|
@@ -54,6 +55,7 @@ module Zip
|
|
54
55
|
@write_zip64_support = false
|
55
56
|
@warn_invalid_date = true
|
56
57
|
@case_insensitive_match = false
|
58
|
+
@validate_entry_sizes = true
|
57
59
|
end
|
58
60
|
|
59
61
|
def setup
|
data/lib/zip/entry.rb
CHANGED
@@ -603,9 +603,21 @@ module Zip
|
|
603
603
|
get_input_stream do |is|
|
604
604
|
set_extra_attributes_on_path(dest_path)
|
605
605
|
|
606
|
+
bytes_written = 0
|
607
|
+
warned = false
|
606
608
|
buf = ''.dup
|
607
609
|
while (buf = is.sysread(::Zip::Decompressor::CHUNK_SIZE, buf))
|
608
610
|
os << buf
|
611
|
+
bytes_written += buf.bytesize
|
612
|
+
if bytes_written > size && !warned
|
613
|
+
message = "Entry #{name} should be #{size}B but is larger when inflated"
|
614
|
+
if ::Zip.validate_entry_sizes
|
615
|
+
raise ::Zip::EntrySizeError, message
|
616
|
+
else
|
617
|
+
puts "WARNING: #{message}"
|
618
|
+
warned = true
|
619
|
+
end
|
620
|
+
end
|
609
621
|
end
|
610
622
|
end
|
611
623
|
end
|
data/lib/zip/errors.rb
CHANGED
data/lib/zip/file.rb
CHANGED
@@ -287,6 +287,13 @@ module Zip
|
|
287
287
|
@entry_set << new_entry
|
288
288
|
end
|
289
289
|
|
290
|
+
# Convenience method for adding the contents of a file to the archive
|
291
|
+
# in Stored format (uncompressed)
|
292
|
+
def add_stored(entry, src_path, &continue_on_exists_proc)
|
293
|
+
entry = ::Zip::Entry.new(@name, entry.to_s, nil, nil, nil, nil, ::Zip::Entry::STORED)
|
294
|
+
add(entry, src_path, &continue_on_exists_proc)
|
295
|
+
end
|
296
|
+
|
290
297
|
# Removes the specified entry.
|
291
298
|
def remove(entry)
|
292
299
|
@entry_set.delete(get_entry(entry))
|
data/lib/zip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyzip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Simonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -134,84 +134,15 @@ files:
|
|
134
134
|
- samples/qtzip.rb
|
135
135
|
- samples/write_simple.rb
|
136
136
|
- samples/zipfind.rb
|
137
|
-
- test/basic_zip_file_test.rb
|
138
|
-
- test/case_sensitivity_test.rb
|
139
|
-
- test/central_directory_entry_test.rb
|
140
|
-
- test/central_directory_test.rb
|
141
|
-
- test/crypto/null_encryption_test.rb
|
142
|
-
- test/crypto/traditional_encryption_test.rb
|
143
|
-
- test/data/WarnInvalidDate.zip
|
144
|
-
- test/data/file1.txt
|
145
|
-
- test/data/file1.txt.deflatedData
|
146
|
-
- test/data/file2.txt
|
147
|
-
- test/data/globTest.zip
|
148
|
-
- test/data/globTest/foo.txt
|
149
|
-
- test/data/globTest/foo/bar/baz/foo.txt
|
150
|
-
- test/data/globTest/food.txt
|
151
|
-
- test/data/gpbit3stored.zip
|
152
|
-
- test/data/mimetype
|
153
|
-
- test/data/notzippedruby.rb
|
154
|
-
- test/data/ntfs.zip
|
155
|
-
- test/data/oddExtraField.zip
|
156
|
-
- test/data/path_traversal/Makefile
|
157
|
-
- test/data/path_traversal/jwilk/README.md
|
158
|
-
- test/data/path_traversal/jwilk/absolute1.zip
|
159
|
-
- test/data/path_traversal/jwilk/absolute2.zip
|
160
|
-
- test/data/path_traversal/jwilk/dirsymlink.zip
|
161
|
-
- test/data/path_traversal/jwilk/dirsymlink2a.zip
|
162
|
-
- test/data/path_traversal/jwilk/dirsymlink2b.zip
|
163
|
-
- test/data/path_traversal/jwilk/relative0.zip
|
164
|
-
- test/data/path_traversal/jwilk/relative2.zip
|
165
|
-
- test/data/path_traversal/jwilk/symlink.zip
|
166
|
-
- test/data/path_traversal/relative1.zip
|
167
|
-
- test/data/path_traversal/tilde.zip
|
168
|
-
- test/data/path_traversal/tuzovakaoff/README.md
|
169
|
-
- test/data/path_traversal/tuzovakaoff/absolutepath.zip
|
170
|
-
- test/data/path_traversal/tuzovakaoff/symlink.zip
|
171
|
-
- test/data/rubycode.zip
|
172
|
-
- test/data/rubycode2.zip
|
173
|
-
- test/data/test.xls
|
174
|
-
- test/data/testDirectory.bin
|
175
|
-
- test/data/zip64-sample.zip
|
176
|
-
- test/data/zipWithDirs.zip
|
177
|
-
- test/data/zipWithEncryption.zip
|
178
|
-
- test/deflater_test.rb
|
179
|
-
- test/encryption_test.rb
|
180
|
-
- test/entry_set_test.rb
|
181
|
-
- test/entry_test.rb
|
182
|
-
- test/errors_test.rb
|
183
|
-
- test/extra_field_test.rb
|
184
|
-
- test/file_extract_directory_test.rb
|
185
|
-
- test/file_extract_test.rb
|
186
|
-
- test/file_permissions_test.rb
|
187
|
-
- test/file_split_test.rb
|
188
|
-
- test/file_test.rb
|
189
|
-
- test/filesystem/dir_iterator_test.rb
|
190
|
-
- test/filesystem/directory_test.rb
|
191
|
-
- test/filesystem/file_mutating_test.rb
|
192
|
-
- test/filesystem/file_nonmutating_test.rb
|
193
|
-
- test/filesystem/file_stat_test.rb
|
194
|
-
- test/gentestfiles.rb
|
195
|
-
- test/inflater_test.rb
|
196
|
-
- test/input_stream_test.rb
|
197
|
-
- test/ioextras/abstract_input_stream_test.rb
|
198
|
-
- test/ioextras/abstract_output_stream_test.rb
|
199
|
-
- test/ioextras/fake_io_test.rb
|
200
|
-
- test/local_entry_test.rb
|
201
|
-
- test/output_stream_test.rb
|
202
|
-
- test/pass_thru_compressor_test.rb
|
203
|
-
- test/pass_thru_decompressor_test.rb
|
204
|
-
- test/path_traversal_test.rb
|
205
|
-
- test/samples/example_recursive_test.rb
|
206
|
-
- test/settings_test.rb
|
207
|
-
- test/test_helper.rb
|
208
|
-
- test/unicode_file_names_and_comments_test.rb
|
209
|
-
- test/zip64_full_test.rb
|
210
|
-
- test/zip64_support_test.rb
|
211
137
|
homepage: http://github.com/rubyzip/rubyzip
|
212
138
|
licenses:
|
213
139
|
- BSD 2-Clause
|
214
|
-
metadata:
|
140
|
+
metadata:
|
141
|
+
bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
|
142
|
+
changelog_uri: https://github.com/rubyzip/rubyzip/blob/v2.0.0/Changelog.md
|
143
|
+
documentation_uri: https://www.rubydoc.info/gems/rubyzip/2.0.0
|
144
|
+
source_code_uri: https://github.com/rubyzip/rubyzip/tree/v2.0.0
|
145
|
+
wiki_uri: https://github.com/rubyzip/rubyzip/wiki
|
215
146
|
post_install_message:
|
216
147
|
rdoc_options: []
|
217
148
|
require_paths:
|
@@ -220,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
151
|
requirements:
|
221
152
|
- - ">="
|
222
153
|
- !ruby/object:Gem::Version
|
223
|
-
version:
|
154
|
+
version: '2.4'
|
224
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
156
|
requirements:
|
226
157
|
- - ">="
|
@@ -231,78 +162,4 @@ rubygems_version: 3.0.3
|
|
231
162
|
signing_key:
|
232
163
|
specification_version: 4
|
233
164
|
summary: rubyzip is a ruby module for reading and writing zip files
|
234
|
-
test_files:
|
235
|
-
- test/file_permissions_test.rb
|
236
|
-
- test/path_traversal_test.rb
|
237
|
-
- test/ioextras/abstract_input_stream_test.rb
|
238
|
-
- test/ioextras/fake_io_test.rb
|
239
|
-
- test/ioextras/abstract_output_stream_test.rb
|
240
|
-
- test/central_directory_test.rb
|
241
|
-
- test/central_directory_entry_test.rb
|
242
|
-
- test/crypto/traditional_encryption_test.rb
|
243
|
-
- test/crypto/null_encryption_test.rb
|
244
|
-
- test/input_stream_test.rb
|
245
|
-
- test/file_extract_directory_test.rb
|
246
|
-
- test/basic_zip_file_test.rb
|
247
|
-
- test/inflater_test.rb
|
248
|
-
- test/file_extract_test.rb
|
249
|
-
- test/pass_thru_compressor_test.rb
|
250
|
-
- test/filesystem/file_nonmutating_test.rb
|
251
|
-
- test/filesystem/file_stat_test.rb
|
252
|
-
- test/filesystem/file_mutating_test.rb
|
253
|
-
- test/filesystem/dir_iterator_test.rb
|
254
|
-
- test/filesystem/directory_test.rb
|
255
|
-
- test/extra_field_test.rb
|
256
|
-
- test/zip64_support_test.rb
|
257
|
-
- test/local_entry_test.rb
|
258
|
-
- test/samples/example_recursive_test.rb
|
259
|
-
- test/entry_test.rb
|
260
|
-
- test/case_sensitivity_test.rb
|
261
|
-
- test/zip64_full_test.rb
|
262
|
-
- test/pass_thru_decompressor_test.rb
|
263
|
-
- test/settings_test.rb
|
264
|
-
- test/gentestfiles.rb
|
265
|
-
- test/encryption_test.rb
|
266
|
-
- test/file_test.rb
|
267
|
-
- test/deflater_test.rb
|
268
|
-
- test/test_helper.rb
|
269
|
-
- test/errors_test.rb
|
270
|
-
- test/file_split_test.rb
|
271
|
-
- test/data/file2.txt
|
272
|
-
- test/data/testDirectory.bin
|
273
|
-
- test/data/globTest/foo.txt
|
274
|
-
- test/data/globTest/foo/bar/baz/foo.txt
|
275
|
-
- test/data/globTest/food.txt
|
276
|
-
- test/data/file1.txt
|
277
|
-
- test/data/rubycode.zip
|
278
|
-
- test/data/WarnInvalidDate.zip
|
279
|
-
- test/data/zipWithDirs.zip
|
280
|
-
- test/data/rubycode2.zip
|
281
|
-
- test/data/mimetype
|
282
|
-
- test/data/zipWithEncryption.zip
|
283
|
-
- test/data/path_traversal/tilde.zip
|
284
|
-
- test/data/path_traversal/Makefile
|
285
|
-
- test/data/path_traversal/relative1.zip
|
286
|
-
- test/data/path_traversal/jwilk/dirsymlink.zip
|
287
|
-
- test/data/path_traversal/jwilk/symlink.zip
|
288
|
-
- test/data/path_traversal/jwilk/README.md
|
289
|
-
- test/data/path_traversal/jwilk/relative2.zip
|
290
|
-
- test/data/path_traversal/jwilk/relative0.zip
|
291
|
-
- test/data/path_traversal/jwilk/absolute2.zip
|
292
|
-
- test/data/path_traversal/jwilk/dirsymlink2b.zip
|
293
|
-
- test/data/path_traversal/jwilk/absolute1.zip
|
294
|
-
- test/data/path_traversal/jwilk/dirsymlink2a.zip
|
295
|
-
- test/data/path_traversal/tuzovakaoff/symlink.zip
|
296
|
-
- test/data/path_traversal/tuzovakaoff/README.md
|
297
|
-
- test/data/path_traversal/tuzovakaoff/absolutepath.zip
|
298
|
-
- test/data/oddExtraField.zip
|
299
|
-
- test/data/gpbit3stored.zip
|
300
|
-
- test/data/ntfs.zip
|
301
|
-
- test/data/notzippedruby.rb
|
302
|
-
- test/data/globTest.zip
|
303
|
-
- test/data/file1.txt.deflatedData
|
304
|
-
- test/data/test.xls
|
305
|
-
- test/data/zip64-sample.zip
|
306
|
-
- test/unicode_file_names_and_comments_test.rb
|
307
|
-
- test/entry_set_test.rb
|
308
|
-
- test/output_stream_test.rb
|
165
|
+
test_files: []
|
data/test/basic_zip_file_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BasicZipFileTest < MiniTest::Test
|
4
|
-
include AssertEntry
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@zip_file = ::Zip::File.new(TestZipFile::TEST_ZIP2.zip_name)
|
8
|
-
@testEntryNameIndex = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_entries
|
12
|
-
assert_equal(TestZipFile::TEST_ZIP2.entry_names.sort,
|
13
|
-
@zip_file.entries.entries.sort.map { |e| e.name })
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_each
|
17
|
-
count = 0
|
18
|
-
visited = {}
|
19
|
-
@zip_file.each do |entry|
|
20
|
-
assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
|
21
|
-
assert(!visited.include?(entry.name))
|
22
|
-
visited[entry.name] = nil
|
23
|
-
count = count.succ
|
24
|
-
end
|
25
|
-
assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_foreach
|
29
|
-
count = 0
|
30
|
-
visited = {}
|
31
|
-
::Zip::File.foreach(TestZipFile::TEST_ZIP2.zip_name) do |entry|
|
32
|
-
assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
|
33
|
-
assert(!visited.include?(entry.name))
|
34
|
-
visited[entry.name] = nil
|
35
|
-
count = count.succ
|
36
|
-
end
|
37
|
-
assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_get_input_stream
|
41
|
-
count = 0
|
42
|
-
visited = {}
|
43
|
-
@zip_file.each do |entry|
|
44
|
-
assert_entry(entry.name, @zip_file.get_input_stream(entry), entry.name)
|
45
|
-
assert(!visited.include?(entry.name))
|
46
|
-
visited[entry.name] = nil
|
47
|
-
count = count.succ
|
48
|
-
end
|
49
|
-
assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_get_input_stream_block
|
53
|
-
fileAndEntryName = @zip_file.entries.first.name
|
54
|
-
@zip_file.get_input_stream(fileAndEntryName) do |zis|
|
55
|
-
assert_entry_contents_for_stream(fileAndEntryName,
|
56
|
-
zis,
|
57
|
-
fileAndEntryName)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|