rubyzip 1.3.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -8
  3. data/Rakefile +3 -0
  4. data/lib/zip.rb +4 -3
  5. data/lib/zip/central_directory.rb +9 -5
  6. data/lib/zip/constants.rb +52 -0
  7. data/lib/zip/crypto/decrypted_io.rb +40 -0
  8. data/lib/zip/crypto/traditional_encryption.rb +9 -9
  9. data/lib/zip/decompressor.rb +19 -1
  10. data/lib/zip/dos_time.rb +12 -7
  11. data/lib/zip/entry.rb +57 -38
  12. data/lib/zip/entry_set.rb +2 -0
  13. data/lib/zip/errors.rb +1 -0
  14. data/lib/zip/extra_field.rb +11 -9
  15. data/lib/zip/extra_field/generic.rb +10 -9
  16. data/lib/zip/extra_field/ntfs.rb +4 -0
  17. data/lib/zip/extra_field/old_unix.rb +3 -1
  18. data/lib/zip/extra_field/universal_time.rb +42 -12
  19. data/lib/zip/extra_field/unix.rb +3 -1
  20. data/lib/zip/extra_field/zip64.rb +4 -2
  21. data/lib/zip/file.rb +79 -54
  22. data/lib/zip/filesystem.rb +193 -177
  23. data/lib/zip/inflater.rb +24 -36
  24. data/lib/zip/input_stream.rb +33 -26
  25. data/lib/zip/ioextras.rb +1 -1
  26. data/lib/zip/ioextras/abstract_input_stream.rb +19 -8
  27. data/lib/zip/ioextras/abstract_output_stream.rb +1 -1
  28. data/lib/zip/null_decompressor.rb +1 -9
  29. data/lib/zip/output_stream.rb +14 -5
  30. data/lib/zip/pass_thru_compressor.rb +2 -2
  31. data/lib/zip/pass_thru_decompressor.rb +13 -22
  32. data/lib/zip/streamable_directory.rb +3 -3
  33. data/lib/zip/streamable_stream.rb +6 -10
  34. data/lib/zip/version.rb +1 -1
  35. data/samples/example.rb +2 -2
  36. data/samples/example_filesystem.rb +1 -1
  37. data/samples/gtk_ruby_zip.rb +19 -19
  38. data/samples/qtzip.rb +6 -6
  39. data/samples/write_simple.rb +2 -4
  40. data/samples/zipfind.rb +23 -22
  41. metadata +28 -169
  42. data/test/basic_zip_file_test.rb +0 -60
  43. data/test/case_sensitivity_test.rb +0 -69
  44. data/test/central_directory_entry_test.rb +0 -69
  45. data/test/central_directory_test.rb +0 -100
  46. data/test/crypto/null_encryption_test.rb +0 -57
  47. data/test/crypto/traditional_encryption_test.rb +0 -80
  48. data/test/data/WarnInvalidDate.zip +0 -0
  49. data/test/data/file1.txt +0 -46
  50. data/test/data/file1.txt.deflatedData +0 -0
  51. data/test/data/file2.txt +0 -1504
  52. data/test/data/globTest.zip +0 -0
  53. data/test/data/globTest/foo.txt +0 -0
  54. data/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  55. data/test/data/globTest/food.txt +0 -0
  56. data/test/data/gpbit3stored.zip +0 -0
  57. data/test/data/mimetype +0 -1
  58. data/test/data/notzippedruby.rb +0 -7
  59. data/test/data/ntfs.zip +0 -0
  60. data/test/data/oddExtraField.zip +0 -0
  61. data/test/data/path_traversal/Makefile +0 -10
  62. data/test/data/path_traversal/jwilk/README.md +0 -5
  63. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  64. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  65. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  66. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  67. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  68. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  69. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  70. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  71. data/test/data/path_traversal/relative1.zip +0 -0
  72. data/test/data/path_traversal/tilde.zip +0 -0
  73. data/test/data/path_traversal/tuzovakaoff/README.md +0 -3
  74. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  75. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  76. data/test/data/rubycode.zip +0 -0
  77. data/test/data/rubycode2.zip +0 -0
  78. data/test/data/test.xls +0 -0
  79. data/test/data/testDirectory.bin +0 -0
  80. data/test/data/zip64-sample.zip +0 -0
  81. data/test/data/zipWithDirs.zip +0 -0
  82. data/test/data/zipWithEncryption.zip +0 -0
  83. data/test/deflater_test.rb +0 -65
  84. data/test/encryption_test.rb +0 -42
  85. data/test/entry_set_test.rb +0 -163
  86. data/test/entry_test.rb +0 -154
  87. data/test/errors_test.rb +0 -35
  88. data/test/extra_field_test.rb +0 -76
  89. data/test/file_extract_directory_test.rb +0 -54
  90. data/test/file_extract_test.rb +0 -145
  91. data/test/file_permissions_test.rb +0 -65
  92. data/test/file_split_test.rb +0 -57
  93. data/test/file_test.rb +0 -666
  94. data/test/filesystem/dir_iterator_test.rb +0 -58
  95. data/test/filesystem/directory_test.rb +0 -139
  96. data/test/filesystem/file_mutating_test.rb +0 -87
  97. data/test/filesystem/file_nonmutating_test.rb +0 -508
  98. data/test/filesystem/file_stat_test.rb +0 -64
  99. data/test/gentestfiles.rb +0 -126
  100. data/test/inflater_test.rb +0 -14
  101. data/test/input_stream_test.rb +0 -182
  102. data/test/ioextras/abstract_input_stream_test.rb +0 -102
  103. data/test/ioextras/abstract_output_stream_test.rb +0 -106
  104. data/test/ioextras/fake_io_test.rb +0 -18
  105. data/test/local_entry_test.rb +0 -154
  106. data/test/output_stream_test.rb +0 -128
  107. data/test/pass_thru_compressor_test.rb +0 -30
  108. data/test/pass_thru_decompressor_test.rb +0 -14
  109. data/test/path_traversal_test.rb +0 -141
  110. data/test/samples/example_recursive_test.rb +0 -37
  111. data/test/settings_test.rb +0 -95
  112. data/test/test_helper.rb +0 -234
  113. data/test/unicode_file_names_and_comments_test.rb +0 -62
  114. data/test/zip64_full_test.rb +0 -51
  115. data/test/zip64_support_test.rb +0 -14
@@ -1,62 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'test_helper'
4
-
5
- class ZipUnicodeFileNamesAndComments < MiniTest::Test
6
- FILENAME = File.join(File.dirname(__FILE__), 'test1.zip')
7
-
8
- def test_unicode_file_name
9
- file_entrys = ['текстовыйфайл.txt', 'Résumé.txt', '슬레이어스휘.txt']
10
- directory_entrys = ['папка/текстовыйфайл.txt', 'Résumé/Résumé.txt', '슬레이어스휘/슬레이어스휘.txt']
11
- stream = ::Zip::OutputStream.open(FILENAME) do |io|
12
- file_entrys.each do |filename|
13
- io.put_next_entry(filename)
14
- io.write(filename)
15
- end
16
- directory_entrys.each do |filepath|
17
- io.put_next_entry(filepath)
18
- io.write(filepath)
19
- end
20
- end
21
- assert(!stream.nil?)
22
- ::Zip::InputStream.open(FILENAME) do |io|
23
- file_entrys.each do |filename|
24
- entry = io.get_next_entry
25
- entry_name = entry.name
26
- entry_name = entry_name.force_encoding('UTF-8')
27
- assert(filename == entry_name)
28
- end
29
- directory_entrys.each do |filepath|
30
- entry = io.get_next_entry
31
- entry_name = entry.name
32
- entry_name = entry_name.force_encoding('UTF-8')
33
- assert(filepath == entry_name)
34
- end
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
-
48
- ::File.unlink(FILENAME)
49
- end
50
-
51
- def test_unicode_comment
52
- str = '渠道升级'
53
- ::Zip::File.open(FILENAME, Zip::File::CREATE) do |z|
54
- z.comment = str
55
- end
56
-
57
- ::Zip::File.open(FILENAME) do |z|
58
- assert(z.comment.force_encoding('UTF-8') == str)
59
- end
60
- ::File.unlink(FILENAME)
61
- end
62
- end
@@ -1,51 +0,0 @@
1
- if ENV['FULL_ZIP64_TEST']
2
- require 'minitest/autorun'
3
- require 'minitest/unit'
4
- require 'fileutils'
5
- require 'zip'
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! ;)
9
-
10
- class Zip64FullTest < MiniTest::Test
11
- def teardown
12
- ::Zip.reset!
13
- end
14
-
15
- def prepare_test_file(test_filename)
16
- ::File.delete(test_filename) if ::File.exist?(test_filename)
17
- test_filename
18
- end
19
-
20
- def test_large_zip_file
21
- ::Zip.write_zip64_support = true
22
- first_text = 'starting out small'
23
- last_text = 'this tests files starting after 4GB in the archive'
24
- test_filename = prepare_test_file('huge.zip')
25
- ::Zip::OutputStream.open(test_filename) do |io|
26
- io.put_next_entry('first_file.txt')
27
- io.write(first_text)
28
-
29
- # write just over 4GB (stored, so the zip file exceeds 4GB)
30
- buf = 'blah' * 16_384
31
- io.put_next_entry('huge_file', nil, nil, ::Zip::Entry::STORED)
32
- 65_537.times { io.write(buf) }
33
-
34
- io.put_next_entry('last_file.txt')
35
- io.write(last_text)
36
- end
37
-
38
- ::Zip::File.open(test_filename) do |zf|
39
- assert_equal %w[first_file.txt huge_file last_file.txt], zf.entries.map(&:name)
40
- assert_equal first_text, zf.read('first_file.txt')
41
- assert_equal last_text, zf.read('last_file.txt')
42
- end
43
-
44
- # note: if this fails, be sure you have UnZip version 6.0 or newer
45
- # as this is the first version to support zip64 extensions
46
- # but some OSes (*cough* OSX) still bundle a 5.xx release
47
- assert system("unzip -tqq #{test_filename}"), 'third-party zip validation failed'
48
- end
49
- end
50
-
51
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Zip64SupportTest < MiniTest::Test
4
- TEST_FILE = File.join(File.dirname(__FILE__), 'data', 'zip64-sample.zip')
5
-
6
- def test_open_zip64_file
7
- zip_file = ::Zip::File.open(TEST_FILE)
8
- assert(!zip_file.nil?)
9
- assert(zip_file.entries.count == 2)
10
- test_rb = zip_file.entries.find { |x| x.name == 'test.rb' }
11
- assert(test_rb.size == 482)
12
- assert(test_rb.compressed_size == 229)
13
- end
14
- end