rubyzip 1.1.6 → 1.1.7
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.
- checksums.yaml +4 -4
- data/README.md +66 -13
- data/lib/zip.rb +5 -1
- data/lib/zip/central_directory.rb +1 -1
- data/lib/zip/crypto/encryption.rb +11 -0
- data/lib/zip/crypto/null_encryption.rb +45 -0
- data/lib/zip/crypto/traditional_encryption.rb +99 -0
- data/lib/zip/deflater.rb +6 -3
- data/lib/zip/entry.rb +11 -5
- data/lib/zip/entry_set.rb +5 -6
- data/lib/zip/extra_field.rb +1 -0
- data/lib/zip/extra_field/ntfs.rb +92 -0
- data/lib/zip/file.rb +11 -1
- data/lib/zip/filesystem.rb +4 -0
- data/lib/zip/inflater.rb +4 -3
- data/lib/zip/input_stream.rb +10 -4
- data/lib/zip/output_stream.rb +12 -7
- data/lib/zip/version.rb +1 -1
- data/test/basic_zip_file_test.rb +1 -1
- data/test/central_directory_entry_test.rb +1 -1
- data/test/central_directory_test.rb +5 -1
- data/test/crypto/null_encryption_test.rb +53 -0
- data/test/crypto/traditional_encryption_test.rb +80 -0
- data/test/data/WarnInvalidDate.zip +0 -0
- data/test/data/ntfs.zip +0 -0
- data/test/data/zipWithEncryption.zip +0 -0
- data/test/deflater_test.rb +14 -9
- data/test/encryption_test.rb +42 -0
- data/test/entry_set_test.rb +14 -1
- data/test/entry_test.rb +2 -2
- data/test/errors_test.rb +1 -1
- data/test/extra_field_test.rb +10 -1
- data/test/file_extract_directory_test.rb +3 -2
- data/test/file_extract_test.rb +2 -2
- data/test/file_split_test.rb +2 -2
- data/test/file_test.rb +16 -13
- data/test/filesystem/dir_iterator_test.rb +1 -1
- data/test/filesystem/directory_test.rb +1 -1
- data/test/filesystem/file_mutating_test.rb +1 -1
- data/test/filesystem/file_nonmutating_test.rb +10 -1
- data/test/filesystem/file_stat_test.rb +1 -1
- data/test/inflater_test.rb +1 -1
- data/test/input_stream_test.rb +1 -1
- data/test/ioextras/abstract_input_stream_test.rb +1 -1
- data/test/ioextras/abstract_output_stream_test.rb +1 -1
- data/test/ioextras/fake_io_test.rb +1 -1
- data/test/local_entry_test.rb +14 -11
- data/test/output_stream_test.rb +18 -3
- data/test/pass_thru_compressor_test.rb +2 -2
- data/test/pass_thru_decompressor_test.rb +1 -1
- data/test/settings_test.rb +23 -2
- data/test/test_helper.rb +1 -1
- data/test/unicode_file_names_and_comments_test.rb +16 -4
- data/test/zip64_full_test.rb +5 -1
- data/test/zip64_support_test.rb +1 -1
- metadata +104 -6
- data/test/dummy.txt +0 -1
data/test/output_stream_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class ZipOutputStreamTest < MiniTest::
|
3
|
+
class ZipOutputStreamTest < MiniTest::Test
|
4
4
|
include AssertEntry
|
5
5
|
|
6
6
|
TEST_ZIP = TestZipFile::TEST_ZIP2.clone
|
7
|
-
TEST_ZIP.zip_name = "output.zip"
|
7
|
+
TEST_ZIP.zip_name = "test/data/generated/output.zip"
|
8
8
|
|
9
9
|
def test_new
|
10
10
|
zos = ::Zip::OutputStream.new(TEST_ZIP.zip_name)
|
@@ -32,6 +32,21 @@ class ZipOutputStreamTest < MiniTest::Unit::TestCase
|
|
32
32
|
assert_test_zip_contents(TEST_ZIP)
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_write_buffer_with_temp_file
|
36
|
+
tmp_file = Tempfile.new('')
|
37
|
+
|
38
|
+
::Zip::OutputStream.write_buffer(tmp_file) do |zos|
|
39
|
+
zos.comment = TEST_ZIP.comment
|
40
|
+
write_test_zip(zos)
|
41
|
+
end
|
42
|
+
|
43
|
+
tmp_file.rewind
|
44
|
+
File.open(TEST_ZIP.zip_name, 'wb') { |f| f.write(tmp_file.read) }
|
45
|
+
tmp_file.unlink
|
46
|
+
|
47
|
+
assert_test_zip_contents(TEST_ZIP)
|
48
|
+
end
|
49
|
+
|
35
50
|
def test_writingToClosedStream
|
36
51
|
assert_i_o_error_in_closed_stream { |zos| zos << "hello world" }
|
37
52
|
assert_i_o_error_in_closed_stream { |zos| zos.puts "hello world" }
|
@@ -99,7 +114,7 @@ class ZipOutputStreamTest < MiniTest::Unit::TestCase
|
|
99
114
|
|
100
115
|
def assert_i_o_error_in_closed_stream
|
101
116
|
assert_raises(IOError) {
|
102
|
-
zos = ::Zip::OutputStream.new("test_putOnClosedStream.zip")
|
117
|
+
zos = ::Zip::OutputStream.new("test/data/generated/test_putOnClosedStream.zip")
|
103
118
|
zos.close
|
104
119
|
yield zos
|
105
120
|
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class PassThruCompressorTest < MiniTest::
|
3
|
+
class PassThruCompressorTest < MiniTest::Test
|
4
4
|
include CrcTest
|
5
5
|
|
6
6
|
def test_size
|
7
|
-
File.open("test/dummy.txt", "wb") {
|
7
|
+
File.open("test/data/generated/dummy.txt", "wb") {
|
8
8
|
|file|
|
9
9
|
compressor = ::Zip::PassThruCompressor.new(file)
|
10
10
|
|
data/test/settings_test.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class ZipSettingsTest < MiniTest::
|
3
|
+
class ZipSettingsTest < MiniTest::Test
|
4
4
|
# TODO Refactor out into common test module
|
5
5
|
include CommonZipFileFixture
|
6
|
-
|
6
|
+
|
7
|
+
TEST_OUT_NAME = "test/data/generated/emptyOutDir"
|
7
8
|
|
8
9
|
def setup
|
9
10
|
super
|
@@ -12,6 +13,10 @@ class ZipSettingsTest < MiniTest::Unit::TestCase
|
|
12
13
|
File.delete(TEST_OUT_NAME) if File.exist? TEST_OUT_NAME
|
13
14
|
end
|
14
15
|
|
16
|
+
def teardown
|
17
|
+
::Zip.reset!
|
18
|
+
end
|
19
|
+
|
15
20
|
def open_zip(&aProc)
|
16
21
|
assert(aProc != nil)
|
17
22
|
::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
|
@@ -62,6 +67,22 @@ class ZipSettingsTest < MiniTest::Unit::TestCase
|
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
70
|
+
def test_false_warn_invalid_date
|
71
|
+
test_file = File.join(File.dirname(__FILE__), 'data', 'WarnInvalidDate.zip')
|
72
|
+
Zip.warn_invalid_date = false
|
73
|
+
|
74
|
+
::Zip::File.open(test_file) do |zf|
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_true_warn_invalid_date
|
79
|
+
test_file = File.join(File.dirname(__FILE__), 'data', 'WarnInvalidDate.zip')
|
80
|
+
Zip.warn_invalid_date = true
|
81
|
+
|
82
|
+
::Zip::File.open(test_file) do |zf|
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
65
86
|
|
66
87
|
private
|
67
88
|
def assert_contains(zf, entryName, filename = entryName)
|
data/test/test_helper.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ZipUnicodeFileNamesAndComments < MiniTest::
|
5
|
+
class ZipUnicodeFileNamesAndComments < MiniTest::Test
|
6
6
|
|
7
7
|
FILENAME = File.join(File.dirname(__FILE__), "test1.zip")
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_unicode_file_name
|
10
10
|
file_entrys = ["текстовыйфайл.txt", "Résumé.txt", "슬레이어스휘.txt"]
|
11
11
|
directory_entrys = ["папка/текстовыйфайл.txt", "Résumé/Résumé.txt", "슬레이어스휘/슬레이어스휘.txt"]
|
12
12
|
stream = ::Zip::OutputStream.open(FILENAME) do |io|
|
@@ -24,17 +24,29 @@ class ZipUnicodeFileNamesAndComments < MiniTest::Unit::TestCase
|
|
24
24
|
file_entrys.each do |filename|
|
25
25
|
entry = io.get_next_entry
|
26
26
|
entry_name = entry.name
|
27
|
-
entry_name = entry_name.force_encoding("UTF-8")
|
27
|
+
entry_name = entry_name.force_encoding("UTF-8")
|
28
28
|
assert(filename == entry_name)
|
29
29
|
end
|
30
30
|
directory_entrys.each do |filepath|
|
31
31
|
entry = io.get_next_entry
|
32
32
|
entry_name = entry.name
|
33
|
-
entry_name = entry_name.force_encoding("UTF-8")
|
33
|
+
entry_name = entry_name.force_encoding("UTF-8")
|
34
34
|
assert(filepath == entry_name)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
::File.unlink(FILENAME)
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_unicode_comment
|
41
|
+
str = '渠道升级'
|
42
|
+
::Zip::File.open(FILENAME, Zip::File::CREATE) do |z|
|
43
|
+
z.comment = str
|
44
|
+
end
|
45
|
+
|
46
|
+
::Zip::File.open(FILENAME) do |z|
|
47
|
+
assert(z.comment.force_encoding('UTF-8') == str)
|
48
|
+
end
|
49
|
+
::File.unlink(FILENAME)
|
50
|
+
end
|
51
|
+
|
40
52
|
end
|
data/test/zip64_full_test.rb
CHANGED
@@ -7,7 +7,11 @@ if ENV['FULL_ZIP64_TEST']
|
|
7
7
|
# test zip64 support for real, by actually exceeding the 32-bit size/offset limits
|
8
8
|
# this test does not, of course, run with the normal unit tests! ;)
|
9
9
|
|
10
|
-
class Zip64FullTest < MiniTest::
|
10
|
+
class Zip64FullTest < MiniTest::Test
|
11
|
+
def teardown
|
12
|
+
::Zip.reset!
|
13
|
+
end
|
14
|
+
|
11
15
|
def prepareTestFile(test_filename)
|
12
16
|
::File.delete(test_filename) if ::File.exist?(test_filename)
|
13
17
|
return test_filename
|
data/test/zip64_support_test.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyzip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Simonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
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
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
13
97
|
description:
|
14
98
|
email:
|
15
99
|
- alex@simonov.me
|
@@ -24,6 +108,9 @@ files:
|
|
24
108
|
- lib/zip/central_directory.rb
|
25
109
|
- lib/zip/compressor.rb
|
26
110
|
- lib/zip/constants.rb
|
111
|
+
- lib/zip/crypto/encryption.rb
|
112
|
+
- lib/zip/crypto/null_encryption.rb
|
113
|
+
- lib/zip/crypto/traditional_encryption.rb
|
27
114
|
- lib/zip/decompressor.rb
|
28
115
|
- lib/zip/deflater.rb
|
29
116
|
- lib/zip/dos_time.rb
|
@@ -32,6 +119,7 @@ files:
|
|
32
119
|
- lib/zip/errors.rb
|
33
120
|
- lib/zip/extra_field.rb
|
34
121
|
- lib/zip/extra_field/generic.rb
|
122
|
+
- lib/zip/extra_field/ntfs.rb
|
35
123
|
- lib/zip/extra_field/old_unix.rb
|
36
124
|
- lib/zip/extra_field/universal_time.rb
|
37
125
|
- lib/zip/extra_field/unix.rb
|
@@ -63,6 +151,9 @@ files:
|
|
63
151
|
- test/basic_zip_file_test.rb
|
64
152
|
- test/central_directory_entry_test.rb
|
65
153
|
- test/central_directory_test.rb
|
154
|
+
- test/crypto/null_encryption_test.rb
|
155
|
+
- test/crypto/traditional_encryption_test.rb
|
156
|
+
- test/data/WarnInvalidDate.zip
|
66
157
|
- test/data/file1.txt
|
67
158
|
- test/data/file1.txt.deflatedData
|
68
159
|
- test/data/file2.txt
|
@@ -72,13 +163,15 @@ files:
|
|
72
163
|
- test/data/globTest/food.txt
|
73
164
|
- test/data/mimetype
|
74
165
|
- test/data/notzippedruby.rb
|
166
|
+
- test/data/ntfs.zip
|
75
167
|
- test/data/rubycode.zip
|
76
168
|
- test/data/rubycode2.zip
|
77
169
|
- test/data/testDirectory.bin
|
78
170
|
- test/data/zip64-sample.zip
|
79
171
|
- test/data/zipWithDirs.zip
|
172
|
+
- test/data/zipWithEncryption.zip
|
80
173
|
- test/deflater_test.rb
|
81
|
-
- test/
|
174
|
+
- test/encryption_test.rb
|
82
175
|
- test/entry_set_test.rb
|
83
176
|
- test/entry_test.rb
|
84
177
|
- test/errors_test.rb
|
@@ -127,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
220
|
version: '0'
|
128
221
|
requirements: []
|
129
222
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.4.5
|
131
224
|
signing_key:
|
132
225
|
specification_version: 4
|
133
226
|
summary: rubyzip is a ruby module for reading and writing zip files
|
@@ -135,6 +228,8 @@ test_files:
|
|
135
228
|
- test/basic_zip_file_test.rb
|
136
229
|
- test/central_directory_entry_test.rb
|
137
230
|
- test/central_directory_test.rb
|
231
|
+
- test/crypto/null_encryption_test.rb
|
232
|
+
- test/crypto/traditional_encryption_test.rb
|
138
233
|
- test/data/file1.txt
|
139
234
|
- test/data/file1.txt.deflatedData
|
140
235
|
- test/data/file2.txt
|
@@ -144,13 +239,16 @@ test_files:
|
|
144
239
|
- test/data/globTest.zip
|
145
240
|
- test/data/mimetype
|
146
241
|
- test/data/notzippedruby.rb
|
242
|
+
- test/data/ntfs.zip
|
147
243
|
- test/data/rubycode.zip
|
148
244
|
- test/data/rubycode2.zip
|
149
245
|
- test/data/testDirectory.bin
|
246
|
+
- test/data/WarnInvalidDate.zip
|
150
247
|
- test/data/zip64-sample.zip
|
151
248
|
- test/data/zipWithDirs.zip
|
249
|
+
- test/data/zipWithEncryption.zip
|
152
250
|
- test/deflater_test.rb
|
153
|
-
- test/
|
251
|
+
- test/encryption_test.rb
|
154
252
|
- test/entry_set_test.rb
|
155
253
|
- test/entry_test.rb
|
156
254
|
- test/errors_test.rb
|
data/test/dummy.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
hello worldbingo
|