rubyzip 1.2.1 → 1.2.2

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -17
  3. data/lib/zip.rb +9 -1
  4. data/lib/zip/central_directory.rb +3 -3
  5. data/lib/zip/compressor.rb +1 -2
  6. data/lib/zip/constants.rb +3 -3
  7. data/lib/zip/crypto/null_encryption.rb +2 -4
  8. data/lib/zip/decompressor.rb +1 -1
  9. data/lib/zip/dos_time.rb +1 -1
  10. data/lib/zip/entry.rb +46 -49
  11. data/lib/zip/entry_set.rb +3 -3
  12. data/lib/zip/extra_field.rb +1 -1
  13. data/lib/zip/extra_field/generic.rb +1 -1
  14. data/lib/zip/extra_field/zip64_placeholder.rb +1 -2
  15. data/lib/zip/file.rb +12 -12
  16. data/lib/zip/filesystem.rb +17 -13
  17. data/lib/zip/inflater.rb +1 -1
  18. data/lib/zip/input_stream.rb +10 -7
  19. data/lib/zip/ioextras/abstract_input_stream.rb +1 -1
  20. data/lib/zip/ioextras/abstract_output_stream.rb +1 -1
  21. data/lib/zip/output_stream.rb +5 -5
  22. data/lib/zip/pass_thru_decompressor.rb +1 -1
  23. data/lib/zip/streamable_stream.rb +1 -1
  24. data/lib/zip/version.rb +1 -1
  25. data/samples/example_recursive.rb +14 -15
  26. data/samples/gtk_ruby_zip.rb +1 -1
  27. data/samples/qtzip.rb +1 -1
  28. data/samples/zipfind.rb +2 -2
  29. data/test/central_directory_entry_test.rb +1 -1
  30. data/test/data/gpbit3stored.zip +0 -0
  31. data/test/data/path_traversal/Makefile +10 -0
  32. data/test/data/path_traversal/jwilk/README.md +5 -0
  33. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  34. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  35. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  36. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  37. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  38. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  39. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  40. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  41. data/test/data/path_traversal/relative1.zip +0 -0
  42. data/test/data/path_traversal/tuzovakaoff/README.md +3 -0
  43. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  44. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  45. data/test/data/rubycode.zip +0 -0
  46. data/test/errors_test.rb +1 -0
  47. data/test/file_permissions_test.rb +11 -15
  48. data/test/file_test.rb +27 -9
  49. data/test/filesystem/dir_iterator_test.rb +1 -1
  50. data/test/filesystem/directory_test.rb +29 -11
  51. data/test/filesystem/file_mutating_test.rb +3 -4
  52. data/test/filesystem/file_nonmutating_test.rb +31 -31
  53. data/test/filesystem/file_stat_test.rb +4 -4
  54. data/test/gentestfiles.rb +13 -13
  55. data/test/input_stream_test.rb +6 -6
  56. data/test/ioextras/abstract_output_stream_test.rb +2 -2
  57. data/test/path_traversal_test.rb +134 -0
  58. data/test/test_helper.rb +2 -2
  59. data/test/unicode_file_names_and_comments_test.rb +12 -0
  60. data/test/zip64_full_test.rb +2 -2
  61. metadata +95 -49
@@ -55,6 +55,12 @@ class ZipFileTest < MiniTest::Test
55
55
  assert_equal(2, zfRead.entries.length)
56
56
  end
57
57
 
58
+ def test_get_input_stream_stored_with_gpflag_bit3
59
+ ::Zip::File.open('test/data/gpbit3stored.zip') do |zf|
60
+ assert_equal("foo\n", zf.read("foo.txt"))
61
+ end
62
+ end
63
+
58
64
  def test_get_output_stream
59
65
  entryCount = nil
60
66
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
@@ -104,6 +110,19 @@ class ZipFileTest < MiniTest::Test
104
110
  end
105
111
  end
106
112
 
113
+ def test_close_buffer_with_stringio
114
+ string_io = StringIO.new File.read('test/data/rubycode.zip')
115
+ zf = ::Zip::File.open_buffer string_io
116
+ assert(zf.close || true) # Poor man's refute_raises
117
+ end
118
+
119
+ def test_close_buffer_with_io
120
+ f = File.open('test/data/rubycode.zip')
121
+ zf = ::Zip::File.open_buffer f
122
+ assert zf.close
123
+ f.close
124
+ end
125
+
107
126
  def test_open_buffer_without_block
108
127
  string_io = StringIO.new File.read('test/data/rubycode.zip')
109
128
  zf = ::Zip::File.open_buffer string_io
@@ -142,15 +161,15 @@ class ZipFileTest < MiniTest::Test
142
161
 
143
162
  def test_recover_permissions_after_add_files_to_archive
144
163
  srcZip = TEST_ZIP.zip_name
145
- ::File.chmod(0664, srcZip)
164
+ ::File.chmod(0o664, srcZip)
146
165
  srcFile = 'test/data/file2.txt'
147
166
  entryName = 'newEntryName.rb'
148
- assert_equal(::File.stat(srcZip).mode, 0100664)
167
+ assert_equal(::File.stat(srcZip).mode, 0o100664)
149
168
  assert(::File.exist?(srcZip))
150
169
  zf = ::Zip::File.new(srcZip, ::Zip::File::CREATE)
151
170
  zf.add(entryName, srcFile)
152
171
  zf.close
153
- assert_equal(::File.stat(srcZip).mode, 0100664)
172
+ assert_equal(::File.stat(srcZip).mode, 0o100664)
154
173
  end
155
174
 
156
175
  def test_add_existing_entry_name
@@ -234,7 +253,7 @@ class ZipFileTest < MiniTest::Test
234
253
  zf.mkdir('test')
235
254
  arr << 'test/'
236
255
  arr_renamed << 'Ztest/'
237
- %w(a b c d).each do |f|
256
+ %w[a b c d].each do |f|
238
257
  zf.get_output_stream("test/#{f}") { |file| file.puts 'aaaa' }
239
258
  arr << "test/#{f}"
240
259
  arr_renamed << "Ztest/#{f}"
@@ -329,7 +348,7 @@ class ZipFileTest < MiniTest::Test
329
348
 
330
349
  def test_replace_non_entry
331
350
  entryToReplace = 'nonExistingEntryname'
332
- ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
351
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
333
352
  assert_raises(Errno::ENOENT) { zf.replace(entryToReplace, 'test/data/file2.txt') }
334
353
  end
335
354
  end
@@ -347,7 +366,7 @@ class ZipFileTest < MiniTest::Test
347
366
  zfRead.close
348
367
 
349
368
  zf.close
350
- res = system("unzip -t #{TEST_ZIP.zip_name}")
369
+ res = system("unzip -tqq #{TEST_ZIP.zip_name}")
351
370
  assert_equal(res, true)
352
371
  end
353
372
 
@@ -363,7 +382,7 @@ class ZipFileTest < MiniTest::Test
363
382
  zf2 = ::Zip::File.open(filename)
364
383
  assert(zf2.entries.detect { |e| e.name == 'test1.txt' } != nil)
365
384
  assert(zf2.entries.detect { |e| e.name == 'test2.txt' } != nil)
366
- res = system("unzip -t #{filename}")
385
+ res = system("unzip -tqq #{filename}")
367
386
  assert_equal(res, true)
368
387
  end
369
388
 
@@ -434,7 +453,6 @@ class ZipFileTest < MiniTest::Test
434
453
  filename_to_remove = originalEntries.map(&:to_s).find { |name| name.match('longBinary') }
435
454
  zf.remove(filename_to_remove)
436
455
  assert_not_contains(zf, filename_to_remove)
437
-
438
456
  ensure
439
457
  zf.close
440
458
  end
@@ -558,7 +576,7 @@ class ZipFileTest < MiniTest::Test
558
576
  entry_count = 0
559
577
  File.open 'test/data/oddExtraField.zip', 'rb' do |zip_io|
560
578
  Zip::File.open_buffer zip_io.read do |zip|
561
- zip.each do |zip_entry|
579
+ zip.each do |_zip_entry|
562
580
  entry_count += 1
563
581
  end
564
582
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'zip/filesystem'
3
3
 
4
4
  class ZipFsDirIteratorTest < MiniTest::Test
5
- FILENAME_ARRAY = %w(f1 f2 f3 f4 f5 f6)
5
+ FILENAME_ARRAY = %w[f1 f2 f3 f4 f5 f6]
6
6
 
7
7
  def setup
8
8
  @dirIt = ::Zip::FileSystem::ZipFsDirIterator.new(FILENAME_ARRAY)
@@ -3,6 +3,7 @@ require 'zip/filesystem'
3
3
 
4
4
  class ZipFsDirectoryTest < MiniTest::Test
5
5
  TEST_ZIP = 'test/data/generated/zipWithDirs_copy.zip'
6
+ GLOB_TEST_ZIP = 'test/data/globTest.zip'
6
7
 
7
8
  def setup
8
9
  FileUtils.cp('test/data/zipWithDirs.zip', TEST_ZIP)
@@ -51,10 +52,10 @@ class ZipFsDirectoryTest < MiniTest::Test
51
52
  zf.dir.chdir 'file1'
52
53
  end
53
54
 
54
- assert_equal(%w(dir1 dir2 file1).sort, zf.dir.entries('.').sort)
55
+ assert_equal(%w[dir1 dir2 file1].sort, zf.dir.entries('.').sort)
55
56
  zf.dir.chdir 'dir1'
56
57
  assert_equal('/dir1', zf.dir.pwd)
57
- assert_equal(%w(dir11 file11 file12), zf.dir.entries('.').sort)
58
+ assert_equal(%w[dir11 file11 file12], zf.dir.entries('.').sort)
58
59
 
59
60
  zf.dir.chdir '../dir2/dir21'
60
61
  assert_equal('/dir2/dir21', zf.dir.pwd)
@@ -77,11 +78,11 @@ class ZipFsDirectoryTest < MiniTest::Test
77
78
 
78
79
  entries = []
79
80
  zf.dir.foreach('.') { |e| entries << e }
80
- assert_equal(%w(dir1 dir2 file1).sort, entries.sort)
81
+ assert_equal(%w[dir1 dir2 file1].sort, entries.sort)
81
82
 
82
83
  entries = []
83
84
  zf.dir.foreach('dir1') { |e| entries << e }
84
- assert_equal(%w(dir11 file11 file12), entries.sort)
85
+ assert_equal(%w[dir11 file11 file12], entries.sort)
85
86
  end
86
87
  end
87
88
 
@@ -93,11 +94,28 @@ class ZipFsDirectoryTest < MiniTest::Test
93
94
  end
94
95
  end
95
96
 
96
- # Globbing not supported yet
97
- # def test_glob
98
- # # test alias []-operator too
99
- # fail "implement test"
100
- # end
97
+ def test_glob
98
+ globbed_files = [
99
+ 'globTest/foo/bar/baz/foo.txt',
100
+ 'globTest/foo.txt',
101
+ 'globTest/food.txt'
102
+ ]
103
+
104
+ ::Zip::File.open(GLOB_TEST_ZIP) do |zf|
105
+ zf.dir.glob('**/*.txt') do |f|
106
+ assert globbed_files.include?(f.name)
107
+ end
108
+
109
+ zf.dir.glob('globTest/foo/**/*.txt') do |f|
110
+ assert_equal globbed_files[0], f.name
111
+ end
112
+
113
+ zf.dir.chdir('globTest/foo')
114
+ zf.dir.glob('**/*.txt') do |f|
115
+ assert_equal globbed_files[0], f.name
116
+ end
117
+ end
118
+ end
101
119
 
102
120
  def test_open_new
103
121
  ::Zip::File.open(TEST_ZIP) do |zf|
@@ -110,11 +128,11 @@ class ZipFsDirectoryTest < MiniTest::Test
110
128
  end
111
129
 
112
130
  d = zf.dir.new('.')
113
- assert_equal(%w(file1 dir1 dir2).sort, d.entries.sort)
131
+ assert_equal(%w[file1 dir1 dir2].sort, d.entries.sort)
114
132
  d.close
115
133
 
116
134
  zf.dir.open('dir1') do |dir|
117
- assert_equal(%w(dir11 file11 file12).sort, dir.entries.sort)
135
+ assert_equal(%w[dir11 file11 file12].sort, dir.entries.sort)
118
136
  end
119
137
  end
120
138
  end
@@ -7,8 +7,7 @@ class ZipFsFileMutatingTest < MiniTest::Test
7
7
  FileUtils.cp('test/data/zipWithDirs.zip', TEST_ZIP)
8
8
  end
9
9
 
10
- def teardown
11
- end
10
+ def teardown; end
12
11
 
13
12
  def test_delete
14
13
  do_test_delete_or_unlink(:delete)
@@ -51,11 +50,11 @@ class ZipFsFileMutatingTest < MiniTest::Test
51
50
 
52
51
  def test_chmod
53
52
  ::Zip::File.open(TEST_ZIP) do |zf|
54
- zf.file.chmod(0765, 'file1')
53
+ zf.file.chmod(0o765, 'file1')
55
54
  end
56
55
 
57
56
  ::Zip::File.open(TEST_ZIP) do |zf|
58
- assert_equal(0100765, zf.file.stat('file1').mode)
57
+ assert_equal(0o100765, zf.file.stat('file1').mode)
59
58
  end
60
59
  end
61
60
 
@@ -14,11 +14,11 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
14
14
 
15
15
  def test_umask
16
16
  assert_equal(::File.umask, @zip_file.file.umask)
17
- @zip_file.file.umask(0006)
17
+ @zip_file.file.umask(0o006)
18
18
  end
19
19
 
20
20
  def test_exists?
21
- assert(! @zip_file.file.exists?('notAFile'))
21
+ assert(!@zip_file.file.exists?('notAFile'))
22
22
  assert(@zip_file.file.exists?('file1'))
23
23
  assert(@zip_file.file.exists?('dir1'))
24
24
  assert(@zip_file.file.exists?('dir1/'))
@@ -114,13 +114,13 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
114
114
  def test_file?
115
115
  assert(@zip_file.file.file?('file1'))
116
116
  assert(@zip_file.file.file?('dir2/file21'))
117
- assert(! @zip_file.file.file?('dir1'))
118
- assert(! @zip_file.file.file?('dir1/dir11'))
117
+ assert(!@zip_file.file.file?('dir1'))
118
+ assert(!@zip_file.file.file?('dir1/dir11'))
119
119
 
120
120
  assert(@zip_file.file.stat('file1').file?)
121
121
  assert(@zip_file.file.stat('dir2/file21').file?)
122
- assert(! @zip_file.file.stat('dir1').file?)
123
- assert(! @zip_file.file.stat('dir1/dir11').file?)
122
+ assert(!@zip_file.file.stat('dir1').file?)
123
+ assert(!@zip_file.file.stat('dir1/dir11').file?)
124
124
  end
125
125
 
126
126
  include ExtraAssertions
@@ -160,15 +160,15 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
160
160
  end
161
161
 
162
162
  def assert_always_false(operation)
163
- assert(! @zip_file.file.send(operation, 'noSuchFile'))
164
- assert(! @zip_file.file.send(operation, 'file1'))
165
- assert(! @zip_file.file.send(operation, 'dir1'))
166
- assert(! @zip_file.file.stat('file1').send(operation))
167
- assert(! @zip_file.file.stat('dir1').send(operation))
163
+ assert(!@zip_file.file.send(operation, 'noSuchFile'))
164
+ assert(!@zip_file.file.send(operation, 'file1'))
165
+ assert(!@zip_file.file.send(operation, 'dir1'))
166
+ assert(!@zip_file.file.stat('file1').send(operation))
167
+ assert(!@zip_file.file.stat('dir1').send(operation))
168
168
  end
169
169
 
170
170
  def assert_true_if_entry_exists(operation)
171
- assert(! @zip_file.file.send(operation, 'noSuchFile'))
171
+ assert(!@zip_file.file.send(operation, 'noSuchFile'))
172
172
  assert(@zip_file.file.send(operation, 'file1'))
173
173
  assert(@zip_file.file.send(operation, 'dir1'))
174
174
  assert(@zip_file.file.stat('file1').send(operation))
@@ -221,15 +221,15 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
221
221
  end
222
222
 
223
223
  def test_directory?
224
- assert(! @zip_file.file.directory?('notAFile'))
225
- assert(! @zip_file.file.directory?('file1'))
226
- assert(! @zip_file.file.directory?('dir1/file11'))
224
+ assert(!@zip_file.file.directory?('notAFile'))
225
+ assert(!@zip_file.file.directory?('file1'))
226
+ assert(!@zip_file.file.directory?('dir1/file11'))
227
227
  assert(@zip_file.file.directory?('dir1'))
228
228
  assert(@zip_file.file.directory?('dir1/'))
229
229
  assert(@zip_file.file.directory?('dir2/dir21'))
230
230
 
231
- assert(! @zip_file.file.stat('file1').directory?)
232
- assert(! @zip_file.file.stat('dir1/file11').directory?)
231
+ assert(!@zip_file.file.stat('file1').directory?)
232
+ assert(!@zip_file.file.stat('dir1/file11').directory?)
233
233
  assert(@zip_file.file.stat('dir1').directory?)
234
234
  assert(@zip_file.file.stat('dir1/').directory?)
235
235
  assert(@zip_file.file.stat('dir2/dir21').directory?)
@@ -243,8 +243,8 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
243
243
  end
244
244
 
245
245
  def test_zero?
246
- assert(! @zip_file.file.zero?('notAFile'))
247
- assert(! @zip_file.file.zero?('file1'))
246
+ assert(!@zip_file.file.zero?('notAFile'))
247
+ assert(!@zip_file.file.zero?('file1'))
248
248
  assert(@zip_file.file.zero?('dir1'))
249
249
  blockCalled = false
250
250
  ::Zip::File.open('test/data/generated/5entry.zip') do |zf|
@@ -253,7 +253,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
253
253
  end
254
254
  assert(blockCalled)
255
255
 
256
- assert(! @zip_file.file.stat('file1').zero?)
256
+ assert(!@zip_file.file.stat('file1').zero?)
257
257
  assert(@zip_file.file.stat('dir1').zero?)
258
258
  blockCalled = false
259
259
  ::Zip::File.open('test/data/generated/5entry.zip') do |zf|
@@ -309,7 +309,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
309
309
  end
310
310
 
311
311
  def test_readable?
312
- assert(! @zip_file.file.readable?('noSuchFile'))
312
+ assert(!@zip_file.file.readable?('noSuchFile'))
313
313
  assert(@zip_file.file.readable?('file1'))
314
314
  assert(@zip_file.file.readable?('dir1'))
315
315
  assert(@zip_file.file.stat('file1').readable?)
@@ -317,7 +317,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
317
317
  end
318
318
 
319
319
  def test_readable_real?
320
- assert(! @zip_file.file.readable_real?('noSuchFile'))
320
+ assert(!@zip_file.file.readable_real?('noSuchFile'))
321
321
  assert(@zip_file.file.readable_real?('file1'))
322
322
  assert(@zip_file.file.readable_real?('dir1'))
323
323
  assert(@zip_file.file.stat('file1').readable_real?)
@@ -325,7 +325,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
325
325
  end
326
326
 
327
327
  def test_writable?
328
- assert(! @zip_file.file.writable?('noSuchFile'))
328
+ assert(!@zip_file.file.writable?('noSuchFile'))
329
329
  assert(@zip_file.file.writable?('file1'))
330
330
  assert(@zip_file.file.writable?('dir1'))
331
331
  assert(@zip_file.file.stat('file1').writable?)
@@ -333,7 +333,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
333
333
  end
334
334
 
335
335
  def test_writable_real?
336
- assert(! @zip_file.file.writable_real?('noSuchFile'))
336
+ assert(!@zip_file.file.writable_real?('noSuchFile'))
337
337
  assert(@zip_file.file.writable_real?('file1'))
338
338
  assert(@zip_file.file.writable_real?('dir1'))
339
339
  assert(@zip_file.file.stat('file1').writable_real?)
@@ -341,18 +341,18 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
341
341
  end
342
342
 
343
343
  def test_executable?
344
- assert(! @zip_file.file.executable?('noSuchFile'))
345
- assert(! @zip_file.file.executable?('file1'))
344
+ assert(!@zip_file.file.executable?('noSuchFile'))
345
+ assert(!@zip_file.file.executable?('file1'))
346
346
  assert(@zip_file.file.executable?('dir1'))
347
- assert(! @zip_file.file.stat('file1').executable?)
347
+ assert(!@zip_file.file.stat('file1').executable?)
348
348
  assert(@zip_file.file.stat('dir1').executable?)
349
349
  end
350
350
 
351
351
  def test_executable_real?
352
- assert(! @zip_file.file.executable_real?('noSuchFile'))
353
- assert(! @zip_file.file.executable_real?('file1'))
352
+ assert(!@zip_file.file.executable_real?('noSuchFile'))
353
+ assert(!@zip_file.file.executable_real?('file1'))
354
354
  assert(@zip_file.file.executable_real?('dir1'))
355
- assert(! @zip_file.file.stat('file1').executable_real?)
355
+ assert(!@zip_file.file.stat('file1').executable_real?)
356
356
  assert(@zip_file.file.stat('dir1').executable_real?)
357
357
  end
358
358
 
@@ -455,7 +455,7 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
455
455
  zf.glob('**/foo.txt') do |match|
456
456
  results << "<#{match.class.name}: #{match}>"
457
457
  end
458
- assert((!results.empty?), 'block not run, or run out of context')
458
+ assert(!results.empty?, 'block not run, or run out of context')
459
459
  assert_equal 2, results.size
460
460
  assert_operator results, :include?, '<Zip::Entry: globTest/foo.txt>'
461
461
  assert_operator results, :include?, '<Zip::Entry: globTest/foo/bar/baz/foo.txt>'
@@ -32,10 +32,10 @@ class ZipFsFileStatTest < MiniTest::Test
32
32
  end
33
33
 
34
34
  def test_mode
35
- assert_equal(0600, @zip_file.file.stat('file1').mode & 0777)
36
- assert_equal(0600, @zip_file.file.stat('file1').mode & 0777)
37
- assert_equal(0755, @zip_file.file.stat('dir1').mode & 0777)
38
- assert_equal(0755, @zip_file.file.stat('dir1').mode & 0777)
35
+ assert_equal(0o600, @zip_file.file.stat('file1').mode & 0o777)
36
+ assert_equal(0o600, @zip_file.file.stat('file1').mode & 0o777)
37
+ assert_equal(0o755, @zip_file.file.stat('dir1').mode & 0o777)
38
+ assert_equal(0o755, @zip_file.file.stat('dir1').mode & 0o777)
39
39
  end
40
40
 
41
41
  def test_dev
@@ -71,12 +71,12 @@ class TestZipFile
71
71
  end
72
72
 
73
73
  def self.create_test_zips
74
- raise "failed to create test zip '#{TEST_ZIP1.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP1.zip_name} test/data/file2.txt")
75
- raise "failed to remove entry from '#{TEST_ZIP1.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP1.zip_name} -d test/data/file2.txt")
74
+ raise "failed to create test zip '#{TEST_ZIP1.zip_name}'" unless system("/usr/bin/zip -q #{TEST_ZIP1.zip_name} test/data/file2.txt")
75
+ raise "failed to remove entry from '#{TEST_ZIP1.zip_name}'" unless system("/usr/bin/zip -q #{TEST_ZIP1.zip_name} -d test/data/file2.txt")
76
76
 
77
77
  File.open('test/data/generated/empty.txt', 'w') {}
78
78
  File.open('test/data/generated/empty_chmod640.txt', 'w') {}
79
- ::File.chmod(0640, 'test/data/generated/empty_chmod640.txt')
79
+ ::File.chmod(0o640, 'test/data/generated/empty_chmod640.txt')
80
80
 
81
81
  File.open('test/data/generated/short.txt', 'w') { |file| file << 'ABCDEF' }
82
82
  ziptestTxt = ''
@@ -93,34 +93,34 @@ class TestZipFile
93
93
  file << testBinaryPattern << rand << "\0" while file.tell < 6E5
94
94
  end
95
95
 
96
- raise "failed to create test zip '#{TEST_ZIP2.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP2.zip_name} #{TEST_ZIP2.entry_names.join(' ')}")
96
+ raise "failed to create test zip '#{TEST_ZIP2.zip_name}'" unless system("/usr/bin/zip -q #{TEST_ZIP2.zip_name} #{TEST_ZIP2.entry_names.join(' ')}")
97
97
 
98
98
  if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
99
- raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless system("echo #{TEST_ZIP2.comment}| /usr/bin/zip -z #{TEST_ZIP2.zip_name}\"")
99
+ raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless system("echo #{TEST_ZIP2.comment}| /usr/bin/zip -zq #{TEST_ZIP2.zip_name}\"")
100
100
  else
101
101
  # without bash system interprets everything after echo as parameters to
102
102
  # echo including | zip -z ...
103
- raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless system("bash -c \"echo #{TEST_ZIP2.comment} | /usr/bin/zip -z #{TEST_ZIP2.zip_name}\"")
103
+ raise "failed to add comment to test zip '#{TEST_ZIP2.zip_name}'" unless system("bash -c \"echo #{TEST_ZIP2.comment} | /usr/bin/zip -zq #{TEST_ZIP2.zip_name}\"")
104
104
  end
105
105
 
106
- raise "failed to create test zip '#{TEST_ZIP3.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP3.zip_name} #{TEST_ZIP3.entry_names.join(' ')}")
106
+ raise "failed to create test zip '#{TEST_ZIP3.zip_name}'" unless system("/usr/bin/zip -q #{TEST_ZIP3.zip_name} #{TEST_ZIP3.entry_names.join(' ')}")
107
107
 
108
- raise "failed to create test zip '#{TEST_ZIP4.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP4.zip_name} #{TEST_ZIP4.entry_names.join(' ')}")
108
+ raise "failed to create test zip '#{TEST_ZIP4.zip_name}'" unless system("/usr/bin/zip -q #{TEST_ZIP4.zip_name} #{TEST_ZIP4.entry_names.join(' ')}")
109
109
  rescue
110
110
  # If there are any Windows developers wanting to use a command line zip.exe
111
111
  # to help create the following files, there's a free one available from
112
112
  # http://stahlworks.com/dev/index.php?tool=zipunzip
113
113
  # that works with the above code
114
114
  raise $!.to_s +
115
- "\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" \
116
- "to create test data. If you don't have it you can download\n" \
117
- 'the necessary test files at http://sf.net/projects/rubyzip.'
115
+ "\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" \
116
+ "to create test data. If you don't have it you can download\n" \
117
+ 'the necessary test files at http://sf.net/projects/rubyzip.'
118
118
  end
119
119
 
120
120
  TEST_ZIP1 = TestZipFile.new('test/data/generated/empty.zip', [])
121
- TEST_ZIP2 = TestZipFile.new('test/data/generated/5entry.zip', %w(test/data/generated/longAscii.txt test/data/generated/empty.txt test/data/generated/empty_chmod640.txt test/data/generated/short.txt test/data/generated/longBinary.bin),
121
+ TEST_ZIP2 = TestZipFile.new('test/data/generated/5entry.zip', %w[test/data/generated/longAscii.txt test/data/generated/empty.txt test/data/generated/empty_chmod640.txt test/data/generated/short.txt test/data/generated/longBinary.bin],
122
122
  'my zip comment')
123
- TEST_ZIP3 = TestZipFile.new('test/data/generated/test1.zip', %w(test/data/file1.txt))
123
+ TEST_ZIP3 = TestZipFile.new('test/data/generated/test1.zip', %w[test/data/file1.txt])
124
124
  TEST_ZIP4 = TestZipFile.new('test/data/generated/zipWithDir.zip', ['test/data/file1.txt',
125
125
  TestFiles::EMPTY_TEST_DIR])
126
126
  end