pdf-reader 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +4 -0
  3. data/lib/pdf/reader/filter/flate.rb +24 -13
  4. metadata +11 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b38615953615bfbca1a80ab344f26166377d8c08d2ba2e05badf43c10682415
4
- data.tar.gz: 658b5d05a14300ad056ee31c10ea998533ccb1b91600e8bc9097070605d003ea
3
+ metadata.gz: 6772a9ffb17b04eaa3c77f2a7e9838a432ecd78506a75cb263f0056d1ace4ec8
4
+ data.tar.gz: 115a94c5b0c8a5367933c438511ec05e2110aaca5589c35a00e6ca76886fa85c
5
5
  SHA512:
6
- metadata.gz: 210b0bee8c4ac009808555c8ba945f3b17b85af22126ac1440eb9b49d91f542f1974b0984efb22726985f2cf8e03440511ebc4664ac5c4d91a6bddea9a43687e
7
- data.tar.gz: 8fb60cb59dc4430179a4b9ba83d30ae6dc23aa13dbef5e8febe1569311ddf7e531783da7e7dd0a6542f0087748e97898af56d540e7c088832f213b48059aa7d3
6
+ metadata.gz: c0bf877470670dd5c0d0cc061fcf1d9ad1f3ec687e66981806c023b9f270719c9045eeebf8c9ffecf07e45102a383438b1f52edb9bb215fea45d51e29aec8f62
7
+ data.tar.gz: bcf0f0bd8baab728d87e5031fd27eaf5386abfbd6111f06e1b7da3232400aed8f93a65675197451329aab6c503f19a5f378af80bc0659018f7dc246da3cb42ea
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v2.4.2 (28th January 2021)
2
+ - relax ASCII85 dependency to allow 1.x
3
+ - improved support for decompressing objects with slightly malformed zlib data
4
+
1
5
  v.2.4.1 (24th September 2020)
2
6
  - Re-vendor font metrics from Adobe to clarify their license
3
7
 
@@ -9,6 +9,7 @@ class PDF::Reader
9
9
  # implementation of the Flate (zlib) stream filter
10
10
  class Flate
11
11
  ZLIB_AUTO_DETECT_ZLIB_OR_GZIP = 47 # Zlib::MAX_WBITS + 32
12
+ ZLIB_RAW_DEFLATE = -15 # Zlib::MAX_WBITS * -1
12
13
 
13
14
  def initialize(options = {})
14
15
  @options = options
@@ -17,24 +18,34 @@ class PDF::Reader
17
18
  ################################################################################
18
19
  # Decode the specified data with the Zlib compression algorithm
19
20
  def filter(data)
20
- deflated = nil
21
+ deflated = zlib_inflate(data) || zlib_inflate(data[0, data.bytesize-1])
22
+
23
+ if deflated.nil?
24
+ raise MalformedPDFError,
25
+ "Error while inflating a compressed stream (no suitable inflation algorithm found)"
26
+ end
27
+ Depredict.new(@options).filter(deflated)
28
+ end
29
+
30
+ private
31
+
32
+ def zlib_inflate(data)
21
33
  begin
22
- deflated = Zlib::Inflate.new(ZLIB_AUTO_DETECT_ZLIB_OR_GZIP).inflate(data)
34
+ return Zlib::Inflate.new(ZLIB_AUTO_DETECT_ZLIB_OR_GZIP).inflate(data)
23
35
  rescue Zlib::DataError => e
24
36
  # by default, Ruby's Zlib assumes the data it's inflating
25
37
  # is RFC1951 deflated data, wrapped in a RFC1950 zlib container. If that
26
- # fails, then use a lightly-documented 'feature' to attempt to inflate
27
- # the data as a raw RFC1951 stream.
28
- #
29
- # See
30
- # - http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/243545
31
- deflated = Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(data)
38
+ # fails, swallow the exception and attempt to inflate the data as a raw
39
+ # RFC1951 stream.
32
40
  end
33
- Depredict.new(@options).filter(deflated)
34
- rescue Exception => e
35
- # Oops, there was a problem inflating the stream
36
- raise MalformedPDFError,
37
- "Error occured while inflating a compressed stream (#{e.class.to_s}: #{e.to_s})"
41
+
42
+ begin
43
+ return Zlib::Inflate.new(ZLIB_RAW_DEFLATE).inflate(data)
44
+ rescue StandardError => e
45
+ # swallow this one too, so we can try some other fallback options
46
+ end
47
+
48
+ nil
38
49
  end
39
50
  end
40
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.0
103
+ version: '1.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: ruby-rc4
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -277,10 +277,10 @@ licenses:
277
277
  - MIT
278
278
  metadata:
279
279
  bug_tracker_uri: https://github.com/yob/pdf-reader/issues
280
- changelog_uri: https://github.com/yob/pdf-reader/blob/v2.4.1/CHANGELOG
281
- documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.4.1
282
- source_code_uri: https://github.com/yob/pdf-reader/tree/v2.4.1
283
- post_install_message:
280
+ changelog_uri: https://github.com/yob/pdf-reader/blob/v2.4.2/CHANGELOG
281
+ documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.4.2
282
+ source_code_uri: https://github.com/yob/pdf-reader/tree/v2.4.2
283
+ post_install_message:
284
284
  rdoc_options:
285
285
  - "--title"
286
286
  - PDF::Reader Documentation
@@ -300,8 +300,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
300
  - !ruby/object:Gem::Version
301
301
  version: '0'
302
302
  requirements: []
303
- rubygems_version: 3.0.3
304
- signing_key:
303
+ rubygems_version: 3.2.3
304
+ signing_key:
305
305
  specification_version: 4
306
306
  summary: A library for accessing the content of PDF files
307
307
  test_files: []