rubyzip 1.1.7 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +143 -54
  3. data/Rakefile +3 -4
  4. data/lib/zip/central_directory.rb +8 -8
  5. data/lib/zip/compressor.rb +1 -2
  6. data/lib/zip/constants.rb +5 -5
  7. data/lib/zip/crypto/null_encryption.rb +4 -6
  8. data/lib/zip/crypto/traditional_encryption.rb +5 -5
  9. data/lib/zip/decompressor.rb +3 -3
  10. data/lib/zip/deflater.rb +8 -6
  11. data/lib/zip/dos_time.rb +5 -6
  12. data/lib/zip/entry.rb +132 -128
  13. data/lib/zip/entry_set.rb +14 -14
  14. data/lib/zip/errors.rb +2 -0
  15. data/lib/zip/extra_field/generic.rb +8 -8
  16. data/lib/zip/extra_field/ntfs.rb +14 -16
  17. data/lib/zip/extra_field/old_unix.rb +9 -10
  18. data/lib/zip/extra_field/universal_time.rb +14 -14
  19. data/lib/zip/extra_field/unix.rb +8 -9
  20. data/lib/zip/extra_field/zip64.rb +12 -11
  21. data/lib/zip/extra_field/zip64_placeholder.rb +1 -2
  22. data/lib/zip/extra_field.rb +8 -8
  23. data/lib/zip/file.rb +88 -81
  24. data/lib/zip/filesystem.rb +144 -143
  25. data/lib/zip/inflater.rb +5 -5
  26. data/lib/zip/input_stream.rb +22 -13
  27. data/lib/zip/ioextras/abstract_input_stream.rb +6 -10
  28. data/lib/zip/ioextras/abstract_output_stream.rb +3 -5
  29. data/lib/zip/ioextras.rb +1 -3
  30. data/lib/zip/null_compressor.rb +2 -2
  31. data/lib/zip/null_decompressor.rb +3 -3
  32. data/lib/zip/null_input_stream.rb +0 -0
  33. data/lib/zip/output_stream.rb +13 -14
  34. data/lib/zip/pass_thru_compressor.rb +4 -4
  35. data/lib/zip/pass_thru_decompressor.rb +3 -4
  36. data/lib/zip/streamable_directory.rb +2 -2
  37. data/lib/zip/streamable_stream.rb +3 -3
  38. data/lib/zip/version.rb +1 -1
  39. data/lib/zip.rb +13 -5
  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 +94 -39
  81. data/test/file_permissions_test.rb +65 -0
  82. data/test/file_split_test.rb +24 -27
  83. data/test/file_test.rb +286 -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 +100 -66
@@ -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.3.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: 2015-02-02 00:00:00.000000000 Z
11
+ date: 2019-09-25 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
@@ -203,7 +211,12 @@ files:
203
211
  homepage: http://github.com/rubyzip/rubyzip
204
212
  licenses:
205
213
  - BSD 2-Clause
206
- metadata: {}
214
+ metadata:
215
+ bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
216
+ changelog_uri: https://github.com/rubyzip/rubyzip/blob/v1.3.0/Changelog.md
217
+ documentation_uri: https://www.rubydoc.info/gems/rubyzip/1.3.0
218
+ source_code_uri: https://github.com/rubyzip/rubyzip/tree/v1.3.0
219
+ wiki_uri: https://github.com/rubyzip/rubyzip/wiki
207
220
  post_install_message:
208
221
  rdoc_options: []
209
222
  require_paths:
@@ -219,61 +232,82 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
232
  - !ruby/object:Gem::Version
220
233
  version: '0'
221
234
  requirements: []
222
- rubyforge_project:
223
- rubygems_version: 2.4.5
235
+ rubygems_version: 3.0.3
224
236
  signing_key:
225
237
  specification_version: 4
226
238
  summary: rubyzip is a ruby module for reading and writing zip files
227
239
  test_files:
228
- - test/basic_zip_file_test.rb
229
- - test/central_directory_entry_test.rb
240
+ - test/file_permissions_test.rb
241
+ - test/path_traversal_test.rb
242
+ - test/ioextras/abstract_input_stream_test.rb
243
+ - test/ioextras/fake_io_test.rb
244
+ - test/ioextras/abstract_output_stream_test.rb
230
245
  - test/central_directory_test.rb
231
- - test/crypto/null_encryption_test.rb
246
+ - test/central_directory_entry_test.rb
232
247
  - 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
248
+ - test/crypto/null_encryption_test.rb
249
+ - test/input_stream_test.rb
256
250
  - test/file_extract_directory_test.rb
251
+ - test/basic_zip_file_test.rb
252
+ - test/inflater_test.rb
257
253
  - 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
254
+ - test/pass_thru_compressor_test.rb
263
255
  - test/filesystem/file_nonmutating_test.rb
264
256
  - 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
257
+ - test/filesystem/file_mutating_test.rb
258
+ - test/filesystem/dir_iterator_test.rb
259
+ - test/filesystem/directory_test.rb
260
+ - test/extra_field_test.rb
261
+ - test/zip64_support_test.rb
271
262
  - test/local_entry_test.rb
272
- - test/output_stream_test.rb
273
- - test/pass_thru_compressor_test.rb
263
+ - test/samples/example_recursive_test.rb
264
+ - test/entry_test.rb
265
+ - test/case_sensitivity_test.rb
266
+ - test/zip64_full_test.rb
274
267
  - test/pass_thru_decompressor_test.rb
275
268
  - test/settings_test.rb
269
+ - test/gentestfiles.rb
270
+ - test/encryption_test.rb
271
+ - test/file_test.rb
272
+ - test/deflater_test.rb
276
273
  - test/test_helper.rb
274
+ - test/errors_test.rb
275
+ - test/file_split_test.rb
276
+ - test/data/file2.txt
277
+ - test/data/testDirectory.bin
278
+ - test/data/globTest/foo.txt
279
+ - test/data/globTest/foo/bar/baz/foo.txt
280
+ - test/data/globTest/food.txt
281
+ - test/data/file1.txt
282
+ - test/data/rubycode.zip
283
+ - test/data/WarnInvalidDate.zip
284
+ - test/data/zipWithDirs.zip
285
+ - test/data/rubycode2.zip
286
+ - test/data/mimetype
287
+ - test/data/zipWithEncryption.zip
288
+ - test/data/path_traversal/tilde.zip
289
+ - test/data/path_traversal/Makefile
290
+ - test/data/path_traversal/relative1.zip
291
+ - test/data/path_traversal/jwilk/dirsymlink.zip
292
+ - test/data/path_traversal/jwilk/symlink.zip
293
+ - test/data/path_traversal/jwilk/README.md
294
+ - test/data/path_traversal/jwilk/relative2.zip
295
+ - test/data/path_traversal/jwilk/relative0.zip
296
+ - test/data/path_traversal/jwilk/absolute2.zip
297
+ - test/data/path_traversal/jwilk/dirsymlink2b.zip
298
+ - test/data/path_traversal/jwilk/absolute1.zip
299
+ - test/data/path_traversal/jwilk/dirsymlink2a.zip
300
+ - test/data/path_traversal/tuzovakaoff/symlink.zip
301
+ - test/data/path_traversal/tuzovakaoff/README.md
302
+ - test/data/path_traversal/tuzovakaoff/absolutepath.zip
303
+ - test/data/oddExtraField.zip
304
+ - test/data/gpbit3stored.zip
305
+ - test/data/ntfs.zip
306
+ - test/data/notzippedruby.rb
307
+ - test/data/globTest.zip
308
+ - test/data/file1.txt.deflatedData
309
+ - test/data/test.xls
310
+ - test/data/zip64-sample.zip
277
311
  - test/unicode_file_names_and_comments_test.rb
278
- - test/zip64_full_test.rb
279
- - test/zip64_support_test.rb
312
+ - test/entry_set_test.rb
313
+ - test/output_stream_test.rb