rubyzip 1.1.7 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubyzip might be problematic. Click here for more details.

Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +87 -45
  3. data/Rakefile +3 -4
  4. data/lib/zip.rb +11 -5
  5. data/lib/zip/central_directory.rb +8 -8
  6. data/lib/zip/compressor.rb +1 -2
  7. data/lib/zip/constants.rb +5 -5
  8. data/lib/zip/crypto/null_encryption.rb +4 -6
  9. data/lib/zip/crypto/traditional_encryption.rb +5 -5
  10. data/lib/zip/decompressor.rb +3 -3
  11. data/lib/zip/deflater.rb +8 -6
  12. data/lib/zip/dos_time.rb +5 -6
  13. data/lib/zip/entry.rb +120 -128
  14. data/lib/zip/entry_set.rb +14 -14
  15. data/lib/zip/errors.rb +1 -0
  16. data/lib/zip/extra_field.rb +8 -8
  17. data/lib/zip/extra_field/generic.rb +8 -8
  18. data/lib/zip/extra_field/ntfs.rb +14 -16
  19. data/lib/zip/extra_field/old_unix.rb +9 -10
  20. data/lib/zip/extra_field/universal_time.rb +14 -14
  21. data/lib/zip/extra_field/unix.rb +8 -9
  22. data/lib/zip/extra_field/zip64.rb +12 -11
  23. data/lib/zip/extra_field/zip64_placeholder.rb +1 -2
  24. data/lib/zip/file.rb +81 -81
  25. data/lib/zip/filesystem.rb +144 -143
  26. data/lib/zip/inflater.rb +5 -5
  27. data/lib/zip/input_stream.rb +22 -13
  28. data/lib/zip/ioextras.rb +1 -3
  29. data/lib/zip/ioextras/abstract_input_stream.rb +6 -10
  30. data/lib/zip/ioextras/abstract_output_stream.rb +3 -5
  31. data/lib/zip/null_compressor.rb +2 -2
  32. data/lib/zip/null_decompressor.rb +3 -3
  33. data/lib/zip/null_input_stream.rb +0 -0
  34. data/lib/zip/output_stream.rb +13 -14
  35. data/lib/zip/pass_thru_compressor.rb +4 -4
  36. data/lib/zip/pass_thru_decompressor.rb +3 -4
  37. data/lib/zip/streamable_directory.rb +2 -2
  38. data/lib/zip/streamable_stream.rb +3 -3
  39. data/lib/zip/version.rb +1 -1
  40. data/samples/example.rb +29 -39
  41. data/samples/example_filesystem.rb +16 -18
  42. data/samples/example_recursive.rb +31 -25
  43. data/samples/{gtkRubyzip.rb → gtk_ruby_zip.rb} +23 -25
  44. data/samples/qtzip.rb +18 -27
  45. data/samples/write_simple.rb +12 -13
  46. data/samples/zipfind.rb +26 -34
  47. data/test/basic_zip_file_test.rb +11 -15
  48. data/test/case_sensitivity_test.rb +69 -0
  49. data/test/central_directory_entry_test.rb +32 -36
  50. data/test/central_directory_test.rb +46 -50
  51. data/test/crypto/null_encryption_test.rb +8 -4
  52. data/test/crypto/traditional_encryption_test.rb +5 -5
  53. data/test/data/gpbit3stored.zip +0 -0
  54. data/test/data/notzippedruby.rb +1 -1
  55. data/test/data/oddExtraField.zip +0 -0
  56. data/test/data/path_traversal/Makefile +10 -0
  57. data/test/data/path_traversal/jwilk/README.md +5 -0
  58. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  59. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  60. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  61. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  62. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  63. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  64. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  65. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  66. data/test/data/path_traversal/relative1.zip +0 -0
  67. data/test/data/path_traversal/tilde.zip +0 -0
  68. data/test/data/path_traversal/tuzovakaoff/README.md +3 -0
  69. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  70. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  71. data/test/data/rubycode.zip +0 -0
  72. data/test/data/test.xls +0 -0
  73. data/test/deflater_test.rb +10 -12
  74. data/test/encryption_test.rb +2 -2
  75. data/test/entry_set_test.rb +50 -25
  76. data/test/entry_test.rb +76 -87
  77. data/test/errors_test.rb +1 -2
  78. data/test/extra_field_test.rb +19 -21
  79. data/test/file_extract_directory_test.rb +12 -14
  80. data/test/file_extract_test.rb +33 -40
  81. data/test/file_permissions_test.rb +65 -0
  82. data/test/file_split_test.rb +24 -27
  83. data/test/file_test.rb +266 -179
  84. data/test/filesystem/dir_iterator_test.rb +13 -17
  85. data/test/filesystem/directory_test.rb +101 -93
  86. data/test/filesystem/file_mutating_test.rb +52 -65
  87. data/test/filesystem/file_nonmutating_test.rb +223 -229
  88. data/test/filesystem/file_stat_test.rb +17 -19
  89. data/test/gentestfiles.rb +54 -62
  90. data/test/inflater_test.rb +1 -1
  91. data/test/input_stream_test.rb +52 -40
  92. data/test/ioextras/abstract_input_stream_test.rb +22 -23
  93. data/test/ioextras/abstract_output_stream_test.rb +33 -33
  94. data/test/ioextras/fake_io_test.rb +1 -1
  95. data/test/local_entry_test.rb +36 -38
  96. data/test/output_stream_test.rb +20 -21
  97. data/test/pass_thru_compressor_test.rb +5 -6
  98. data/test/pass_thru_decompressor_test.rb +0 -1
  99. data/test/path_traversal_test.rb +141 -0
  100. data/test/samples/example_recursive_test.rb +37 -0
  101. data/test/settings_test.rb +18 -15
  102. data/test/test_helper.rb +52 -46
  103. data/test/unicode_file_names_and_comments_test.rb +17 -7
  104. data/test/zip64_full_test.rb +10 -12
  105. data/test/zip64_support_test.rb +0 -1
  106. metadata +94 -65
@@ -3,12 +3,11 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class ZipUnicodeFileNamesAndComments < MiniTest::Test
6
-
7
- FILENAME = File.join(File.dirname(__FILE__), "test1.zip")
6
+ FILENAME = File.join(File.dirname(__FILE__), 'test1.zip')
8
7
 
9
8
  def test_unicode_file_name
10
- file_entrys = ["текстовыйфайл.txt", "Résumé.txt", "슬레이어스휘.txt"]
11
- directory_entrys = ["папка/текстовыйфайл.txt", "Résumé/Résumé.txt", "슬레이어스휘/슬레이어스휘.txt"]
9
+ file_entrys = ['текстовыйфайл.txt', 'Résumé.txt', '슬레이어스휘.txt']
10
+ directory_entrys = ['папка/текстовыйфайл.txt', 'Résumé/Résumé.txt', '슬레이어스휘/슬레이어스휘.txt']
12
11
  stream = ::Zip::OutputStream.open(FILENAME) do |io|
13
12
  file_entrys.each do |filename|
14
13
  io.put_next_entry(filename)
@@ -24,16 +23,28 @@ class ZipUnicodeFileNamesAndComments < MiniTest::Test
24
23
  file_entrys.each do |filename|
25
24
  entry = io.get_next_entry
26
25
  entry_name = entry.name
27
- entry_name = entry_name.force_encoding("UTF-8")
26
+ entry_name = entry_name.force_encoding('UTF-8')
28
27
  assert(filename == entry_name)
29
28
  end
30
29
  directory_entrys.each do |filepath|
31
30
  entry = io.get_next_entry
32
31
  entry_name = entry.name
33
- entry_name = entry_name.force_encoding("UTF-8")
32
+ entry_name = entry_name.force_encoding('UTF-8')
34
33
  assert(filepath == entry_name)
35
34
  end
36
35
  end
36
+
37
+ ::Zip.force_entry_names_encoding = 'UTF-8'
38
+ ::Zip::File.open(FILENAME) do |zip|
39
+ file_entrys.each do |filename|
40
+ refute_nil(zip.find_entry(filename))
41
+ end
42
+ directory_entrys.each do |filepath|
43
+ refute_nil(zip.find_entry(filepath))
44
+ end
45
+ end
46
+ ::Zip.force_entry_names_encoding = nil
47
+
37
48
  ::File.unlink(FILENAME)
38
49
  end
39
50
 
@@ -48,5 +59,4 @@ class ZipUnicodeFileNamesAndComments < MiniTest::Test
48
59
  end
49
60
  ::File.unlink(FILENAME)
50
61
  end
51
-
52
62
  end
@@ -4,39 +4,39 @@ if ENV['FULL_ZIP64_TEST']
4
4
  require 'fileutils'
5
5
  require 'zip'
6
6
 
7
- # test zip64 support for real, by actually exceeding the 32-bit size/offset limits
8
- # this test does not, of course, run with the normal unit tests! ;)
7
+ # test zip64 support for real, by actually exceeding the 32-bit size/offset limits
8
+ # this test does not, of course, run with the normal unit tests! ;)
9
9
 
10
10
  class Zip64FullTest < MiniTest::Test
11
11
  def teardown
12
12
  ::Zip.reset!
13
13
  end
14
14
 
15
- def prepareTestFile(test_filename)
15
+ def prepare_test_file(test_filename)
16
16
  ::File.delete(test_filename) if ::File.exist?(test_filename)
17
- return test_filename
17
+ test_filename
18
18
  end
19
19
 
20
- def test_largeZipFile
20
+ def test_large_zip_file
21
21
  ::Zip.write_zip64_support = true
22
22
  first_text = 'starting out small'
23
23
  last_text = 'this tests files starting after 4GB in the archive'
24
- test_filename = prepareTestFile('huge.zip')
24
+ test_filename = prepare_test_file('huge.zip')
25
25
  ::Zip::OutputStream.open(test_filename) do |io|
26
26
  io.put_next_entry('first_file.txt')
27
27
  io.write(first_text)
28
28
 
29
29
  # write just over 4GB (stored, so the zip file exceeds 4GB)
30
- buf = 'blah' * 16384
30
+ buf = 'blah' * 16_384
31
31
  io.put_next_entry('huge_file', nil, nil, ::Zip::Entry::STORED)
32
- 65537.times { io.write(buf) }
32
+ 65_537.times { io.write(buf) }
33
33
 
34
34
  io.put_next_entry('last_file.txt')
35
35
  io.write(last_text)
36
36
  end
37
37
 
38
38
  ::Zip::File.open(test_filename) do |zf|
39
- assert_equal %w(first_file.txt huge_file last_file.txt), zf.entries.map(&:name)
39
+ assert_equal %w[first_file.txt huge_file last_file.txt], zf.entries.map(&:name)
40
40
  assert_equal first_text, zf.read('first_file.txt')
41
41
  assert_equal last_text, zf.read('last_file.txt')
42
42
  end
@@ -44,10 +44,8 @@ if ENV['FULL_ZIP64_TEST']
44
44
  # note: if this fails, be sure you have UnZip version 6.0 or newer
45
45
  # as this is the first version to support zip64 extensions
46
46
  # but some OSes (*cough* OSX) still bundle a 5.xx release
47
- assert system("unzip -t #{test_filename}"), "third-party zip validation failed"
47
+ assert system("unzip -tqq #{test_filename}"), 'third-party zip validation failed'
48
48
  end
49
-
50
49
  end
51
50
 
52
51
  end
53
-
@@ -11,5 +11,4 @@ class Zip64SupportTest < MiniTest::Test
11
11
  assert(test_rb.size == 482)
12
12
  assert(test_rb.compressed_size == 229)
13
13
  end
14
-
15
14
  end
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: 1.1.7
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Simonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-02 00:00:00.000000000 Z
11
+ date: 2019-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -67,33 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.7'
69
69
  - !ruby/object:Gem::Dependency
70
- name: guard
70
+ name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: guard-minitest
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: 0.49.1
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: 0.49.1
97
83
  description:
98
84
  email:
99
85
  - alex@simonov.me
@@ -144,11 +130,12 @@ files:
144
130
  - samples/example.rb
145
131
  - samples/example_filesystem.rb
146
132
  - samples/example_recursive.rb
147
- - samples/gtkRubyzip.rb
133
+ - samples/gtk_ruby_zip.rb
148
134
  - samples/qtzip.rb
149
135
  - samples/write_simple.rb
150
136
  - samples/zipfind.rb
151
137
  - test/basic_zip_file_test.rb
138
+ - test/case_sensitivity_test.rb
152
139
  - test/central_directory_entry_test.rb
153
140
  - test/central_directory_test.rb
154
141
  - test/crypto/null_encryption_test.rb
@@ -161,11 +148,29 @@ files:
161
148
  - test/data/globTest/foo.txt
162
149
  - test/data/globTest/foo/bar/baz/foo.txt
163
150
  - test/data/globTest/food.txt
151
+ - test/data/gpbit3stored.zip
164
152
  - test/data/mimetype
165
153
  - test/data/notzippedruby.rb
166
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
167
171
  - test/data/rubycode.zip
168
172
  - test/data/rubycode2.zip
173
+ - test/data/test.xls
169
174
  - test/data/testDirectory.bin
170
175
  - test/data/zip64-sample.zip
171
176
  - test/data/zipWithDirs.zip
@@ -178,6 +183,7 @@ files:
178
183
  - test/extra_field_test.rb
179
184
  - test/file_extract_directory_test.rb
180
185
  - test/file_extract_test.rb
186
+ - test/file_permissions_test.rb
181
187
  - test/file_split_test.rb
182
188
  - test/file_test.rb
183
189
  - test/filesystem/dir_iterator_test.rb
@@ -195,6 +201,8 @@ files:
195
201
  - test/output_stream_test.rb
196
202
  - test/pass_thru_compressor_test.rb
197
203
  - test/pass_thru_decompressor_test.rb
204
+ - test/path_traversal_test.rb
205
+ - test/samples/example_recursive_test.rb
198
206
  - test/settings_test.rb
199
207
  - test/test_helper.rb
200
208
  - test/unicode_file_names_and_comments_test.rb
@@ -219,61 +227,82 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
227
  - !ruby/object:Gem::Version
220
228
  version: '0'
221
229
  requirements: []
222
- rubyforge_project:
223
- rubygems_version: 2.4.5
230
+ rubygems_version: 3.0.3
224
231
  signing_key:
225
232
  specification_version: 4
226
233
  summary: rubyzip is a ruby module for reading and writing zip files
227
234
  test_files:
228
- - test/basic_zip_file_test.rb
229
- - test/central_directory_entry_test.rb
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
230
240
  - test/central_directory_test.rb
231
- - test/crypto/null_encryption_test.rb
241
+ - test/central_directory_entry_test.rb
232
242
  - test/crypto/traditional_encryption_test.rb
233
- - test/data/file1.txt
234
- - test/data/file1.txt.deflatedData
235
- - test/data/file2.txt
236
- - test/data/globTest/foo/bar/baz/foo.txt
237
- - test/data/globTest/foo.txt
238
- - test/data/globTest/food.txt
239
- - test/data/globTest.zip
240
- - test/data/mimetype
241
- - test/data/notzippedruby.rb
242
- - test/data/ntfs.zip
243
- - test/data/rubycode.zip
244
- - test/data/rubycode2.zip
245
- - test/data/testDirectory.bin
246
- - test/data/WarnInvalidDate.zip
247
- - test/data/zip64-sample.zip
248
- - test/data/zipWithDirs.zip
249
- - test/data/zipWithEncryption.zip
250
- - test/deflater_test.rb
251
- - test/encryption_test.rb
252
- - test/entry_set_test.rb
253
- - test/entry_test.rb
254
- - test/errors_test.rb
255
- - test/extra_field_test.rb
243
+ - test/crypto/null_encryption_test.rb
244
+ - test/input_stream_test.rb
256
245
  - test/file_extract_directory_test.rb
246
+ - test/basic_zip_file_test.rb
247
+ - test/inflater_test.rb
257
248
  - test/file_extract_test.rb
258
- - test/file_split_test.rb
259
- - test/file_test.rb
260
- - test/filesystem/dir_iterator_test.rb
261
- - test/filesystem/directory_test.rb
262
- - test/filesystem/file_mutating_test.rb
249
+ - test/pass_thru_compressor_test.rb
263
250
  - test/filesystem/file_nonmutating_test.rb
264
251
  - test/filesystem/file_stat_test.rb
265
- - test/gentestfiles.rb
266
- - test/inflater_test.rb
267
- - test/input_stream_test.rb
268
- - test/ioextras/abstract_input_stream_test.rb
269
- - test/ioextras/abstract_output_stream_test.rb
270
- - test/ioextras/fake_io_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
271
257
  - test/local_entry_test.rb
272
- - test/output_stream_test.rb
273
- - test/pass_thru_compressor_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
274
262
  - test/pass_thru_decompressor_test.rb
275
263
  - test/settings_test.rb
264
+ - test/gentestfiles.rb
265
+ - test/encryption_test.rb
266
+ - test/file_test.rb
267
+ - test/deflater_test.rb
276
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
277
306
  - test/unicode_file_names_and_comments_test.rb
278
- - test/zip64_full_test.rb
279
- - test/zip64_support_test.rb
307
+ - test/entry_set_test.rb
308
+ - test/output_stream_test.rb