format_parser 0.22.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13d1f2a3748d62b027f80b1d6c46f8d087ddfc9cbeadeb62b330fa397797b847
4
- data.tar.gz: eea08816482a939538aa1400ba6ca29af864f33ac12d960cbad8806d0e13a9c8
3
+ metadata.gz: 05470fef0edec68c427b9680cf94a88a8f3286e2279b2daf13e87679324eb061
4
+ data.tar.gz: f65ed1d390e4e70bd34a3b01b5d54d39e4076d18ebf15fc20196c2746c86122f
5
5
  SHA512:
6
- metadata.gz: d21c310453155285236e3469ad9980df4d408b00b989fa5a9ed330f39c0c4f5a65ebfb84a79d7f9d7c9761c9dbf27958b8b44a5e8176f79cbf340b011279a0c0
7
- data.tar.gz: 0e8949ac9c1ac6624f27539fe33f52c28c7e5b9c2cce83d9c752372653e35c0231d9a087cff88c9ea87585eaa7dcd8d6878a1345b5b914554d4a5691f11dce60
6
+ metadata.gz: e6e9e2d1fbfe6e813d1e0d9d2c102ce3f031fd37395cc75807ca7b527b1a2fc4a9a3c41baaf9e2cdaa601063cded92ef446ce913f2210f3d82e063126873d54d
7
+ data.tar.gz: 86e166b2ac754fe5d7e42e471bcaa70cd54ae0aa22da3e0f85a6223213c2bd5a284f2b53416d03656dc291898837636678dbfba2e32b179a562ea7c8b05ef0bf
@@ -1,3 +1,6 @@
1
+ ## 0.22.1
2
+ * Fix Zip parser to not raise error for invalid zip files, with an invalid central directory
3
+
1
4
  ## 0.22.0
2
5
  * Adds option `stringify_keys: true` to #as_json methods (fix #151)
3
6
 
@@ -234,4 +234,9 @@ This provision also applies to the test files you include with the changed code
234
234
 
235
235
  ## Changelog
236
236
 
237
- When creating a new release you must add an entry in the `CHANGELOG.md`.
237
+ When creating a new release you must add an entry in the `CHANGELOG.md`.
238
+
239
+ ## Testing locally
240
+
241
+ It's possible to run `exe/format_parser_inspect FILE_NAME` or `exe/format_parser_inspect FILE_URI`
242
+ to test the new code without the necessity of installing the gem.
@@ -1,3 +1,3 @@
1
1
  module FormatParser
2
- VERSION = '0.22.0'
2
+ VERSION = '0.22.1'
3
3
  end
@@ -18,6 +18,7 @@ class FormatParser::ZIPParser::FileReader
18
18
  'Could not find the EOCD signature in the buffer - maybe a malformed ZIP file'
19
19
  end
20
20
  end
21
+ InvalidCentralDirectory = Class.new(Error)
21
22
 
22
23
  C_UINT32LE = 'V'
23
24
  C_UINT16LE = 'v'
@@ -175,6 +176,8 @@ class FormatParser::ZIPParser::FileReader
175
176
  # BUT! in format_parser we avoid unbounded reads, as a matter of fact they are forbidden.
176
177
  # So we will again limit ouselves to cdir_size, and we will take cushion of 1 KB.
177
178
  central_directory_str = io.read(cdir_size + 1024)
179
+ raise InvalidCentralDirectory if central_directory_str.nil?
180
+
178
181
  central_directory_io = StringIO.new(central_directory_str)
179
182
  log do
180
183
  format(
@@ -103,4 +103,11 @@ describe FormatParser::ZIPParser do
103
103
  expect(first_entry.filename).to eq('Li��nia Extreme//')
104
104
  expect(first_entry.type).to eq(:directory)
105
105
  end
106
+
107
+ it 'is able to handle files with invalid central directory position' do
108
+ invalid_zip_path = fixtures_dir + '/ZIP/invalid_central_directory.zip'
109
+
110
+ expect { subject.call(File.open(invalid_zip_path, 'rb')) }
111
+ .to_not raise_error
112
+ end
106
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Berman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-07-15 00:00:00.000000000 Z
12
+ date: 2020-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ks
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  - !ruby/object:Gem::Version
294
294
  version: '0'
295
295
  requirements: []
296
- rubygems_version: 3.1.4
296
+ rubygems_version: 3.0.3
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: A library for efficient parsing of file metadata