rubyzip 1.3.0 → 2.3.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 +2 -8
- data/Rakefile +3 -0
- data/lib/zip.rb +4 -3
- data/lib/zip/central_directory.rb +9 -5
- data/lib/zip/constants.rb +52 -0
- data/lib/zip/crypto/decrypted_io.rb +40 -0
- data/lib/zip/crypto/traditional_encryption.rb +9 -9
- data/lib/zip/decompressor.rb +19 -1
- data/lib/zip/dos_time.rb +12 -7
- data/lib/zip/entry.rb +57 -38
- data/lib/zip/entry_set.rb +2 -0
- data/lib/zip/errors.rb +1 -0
- data/lib/zip/extra_field.rb +11 -9
- data/lib/zip/extra_field/generic.rb +10 -9
- data/lib/zip/extra_field/ntfs.rb +4 -0
- data/lib/zip/extra_field/old_unix.rb +3 -1
- data/lib/zip/extra_field/universal_time.rb +42 -12
- data/lib/zip/extra_field/unix.rb +3 -1
- data/lib/zip/extra_field/zip64.rb +4 -2
- data/lib/zip/file.rb +79 -54
- data/lib/zip/filesystem.rb +193 -177
- data/lib/zip/inflater.rb +24 -36
- data/lib/zip/input_stream.rb +33 -26
- data/lib/zip/ioextras.rb +1 -1
- data/lib/zip/ioextras/abstract_input_stream.rb +19 -8
- data/lib/zip/ioextras/abstract_output_stream.rb +1 -1
- data/lib/zip/null_decompressor.rb +1 -9
- data/lib/zip/output_stream.rb +14 -5
- data/lib/zip/pass_thru_compressor.rb +2 -2
- data/lib/zip/pass_thru_decompressor.rb +13 -22
- data/lib/zip/streamable_directory.rb +3 -3
- data/lib/zip/streamable_stream.rb +6 -10
- data/lib/zip/version.rb +1 -1
- data/samples/example.rb +2 -2
- data/samples/example_filesystem.rb +1 -1
- data/samples/gtk_ruby_zip.rb +19 -19
- data/samples/qtzip.rb +6 -6
- data/samples/write_simple.rb +2 -4
- data/samples/zipfind.rb +23 -22
- metadata +28 -169
- 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 -145
- data/test/file_permissions_test.rb +0 -65
- data/test/file_split_test.rb +0 -57
- data/test/file_test.rb +0 -666
- 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
@@ -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
|
data/test/zip64_full_test.rb
DELETED
@@ -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
|
data/test/zip64_support_test.rb
DELETED
@@ -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
|