hexapdf 0.32.1 → 0.32.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bee477049a8d45aa858093fa683fef19c4760626c3368bf782b74ca10c26d4e1
4
- data.tar.gz: e543e4d73eaf80d6f6e434e499715de454f43fb7dae789773282236c2154bc57
3
+ metadata.gz: f0907362b897b39d61fa8f859510ccfb31ebd5ad88b94a9e36ff62c62fae813a
4
+ data.tar.gz: 469465941253bad5e769fc0dd5a57e437c578fdecda52a0fea908370ef8b7169
5
5
  SHA512:
6
- metadata.gz: d2204bac09267cc3459511a4580480b6157dc5eceafd34c61881dbbcc5c52cc457e7862b3d888d0aa5b8260470b38febf2779ee442f697ce971f82044d81f7ee
7
- data.tar.gz: b77bbcb040ab16e98d3023447a96d7d942a8c80613969bece44ee96427d9235d6db25446dc1ddf6db6ba1f9d0010f4d4f076fdc7ee189947e7ab4cf94a871807
6
+ metadata.gz: 2fc77d33ddc2c6fb377a778b82f92f01fed93d9a4e494cd57c97dc0a00fce4baa7cab185776f8a3303507d68b544e4404ac2f33b72c3b1a7cc7c65ee838c7dd7
7
+ data.tar.gz: 21a08984f424b91594a2d8e6fc705a7f9458a990918ee77adef469e758ae2fee976ba905a7a4a696c5c2728831d02f8845dc9b5316c28de4ff5c7f062521a7e3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.32.2 - 2023-05-06
2
+
3
+ ### Changed
4
+
5
+ * Cross-reference table reconstruction to be more relaxed concerning the
6
+ `endobj` keyword
7
+
8
+ ### Fixed
9
+
10
+ * [HexaPDF::Type::ObjectStream] to not compress any encryption dictionary
11
+ instead of only the current one
12
+
13
+
1
14
  ## 0.32.1 - 2023-04-20
2
15
 
3
16
  ### Added
data/lib/hexapdf/cli.rb CHANGED
@@ -62,6 +62,10 @@ module HexaPDF
62
62
  Application.new.parse(args)
63
63
  rescue StandardError => e
64
64
  $stderr.puts "Problem encountered: #{e.message}"
65
+ unless e.kind_of?(HexaPDF::Error)
66
+ $stderr.puts "--> The problem might indicate a faulty PDF or a bug in HexaPDF."
67
+ $stderr.puts "--> Please report this at https://github.com/gettalong/hexapdf/issues - thanks!"
68
+ end
65
69
  exit(1)
66
70
  end
67
71
 
@@ -458,7 +458,7 @@ module HexaPDF
458
458
  linearized = obj.kind_of?(Hash) && obj.key?(:Linearized)
459
459
  @tokenizer.pos = pos
460
460
  end
461
- @tokenizer.scan_until(/(?:\n|\r\n?)endobj\b/)
461
+ @tokenizer.scan_until(/\bendobj\b/)
462
462
  end
463
463
  elsif token.kind_of?(Tokenizer::Token) && token == 'trailer'
464
464
  obj = @tokenizer.next_object rescue nil
@@ -172,13 +172,16 @@ module HexaPDF
172
172
  serializer = Serializer.new
173
173
  obj_to_stm = {}
174
174
 
175
- encrypt_dict = document.trailer[:Encrypt]
175
+ is_encrypt_dict = document.revisions.each.with_object({}) do |rev, hash|
176
+ hash[rev.trailer[:Encrypt]] = true
177
+ end
176
178
  while index < objects.size / 2
177
179
  obj = revision.object(objects[index])
178
180
 
179
181
  # Due to a bug in Adobe Acrobat, the Catalog may not be in an object stream if the
180
182
  # document is encrypted
181
- if obj.nil? || obj.null? || obj.gen != 0 || obj.kind_of?(Stream) || obj == encrypt_dict ||
183
+ if obj.nil? || obj.null? || obj.gen != 0 || obj.kind_of?(Stream) ||
184
+ is_encrypt_dict[obj] ||
182
185
  obj.type == :Catalog ||
183
186
  obj.type == :Sig || obj.type == :DocTimeStamp ||
184
187
  (obj.respond_to?(:key?) && obj.key?(:ByteRange) && obj.key?(:Contents))
@@ -37,6 +37,6 @@
37
37
  module HexaPDF
38
38
 
39
39
  # The version of HexaPDF.
40
- VERSION = '0.32.1'
40
+ VERSION = '0.32.2'
41
41
 
42
42
  end
@@ -609,7 +609,7 @@ describe HexaPDF::Parser do
609
609
  end
610
610
 
611
611
  it "serially parses the contents" do
612
- create_parser("1 0 obj\n5\nendobj\n1 0 obj\n6\nendobj\ntrailer\n<</Size 1>>")
612
+ create_parser("1 0 obj\n5 endobj\n1 0 obj\n6\nendobj\ntrailer\n<</Size 1>>")
613
613
  assert_equal(6, @parser.load_object(@xref).value)
614
614
  end
615
615
 
@@ -40,7 +40,7 @@ describe HexaPDF::Writer do
40
40
  219
41
41
  %%EOF
42
42
  3 0 obj
43
- <</Producer(HexaPDF version 0.32.1)>>
43
+ <</Producer(HexaPDF version 0.32.2)>>
44
44
  endobj
45
45
  xref
46
46
  3 1
@@ -72,7 +72,7 @@ describe HexaPDF::Writer do
72
72
  141
73
73
  %%EOF
74
74
  6 0 obj
75
- <</Producer(HexaPDF version 0.32.1)>>
75
+ <</Producer(HexaPDF version 0.32.2)>>
76
76
  endobj
77
77
  2 0 obj
78
78
  <</Length 10>>stream
@@ -214,7 +214,7 @@ describe HexaPDF::Writer do
214
214
  <</Type/Page/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<<>>>>
215
215
  endobj
216
216
  5 0 obj
217
- <</Producer(HexaPDF version 0.32.1)>>
217
+ <</Producer(HexaPDF version 0.32.2)>>
218
218
  endobj
219
219
  4 0 obj
220
220
  <</Root 1 0 R/Info 5 0 R/Size 6/Type/XRef/W[1 1 2]/Index[0 6]/Filter/FlateDecode/DecodeParms<</Columns 4/Predictor 12>>/Length 33>>stream
@@ -23,9 +23,14 @@ describe HexaPDF::Type::ObjectStream do
23
23
  before do
24
24
  @doc = Object.new
25
25
  @doc.instance_variable_set(:@version, '1.5')
26
- def (@doc).trailer
27
- @trailer ||= {Encrypt: HexaPDF::Object.new({}, oid: 9)}
26
+ @doc.define_singleton_method(:revisions) do
27
+ rev1 = Object.new
28
+ def rev1.trailer; {Encrypt: HexaPDF::Object.new({}, oid: 10)}; end
29
+ rev2 = Object.new
30
+ def rev2.trailer; {Encrypt: HexaPDF::Object.new({}, oid: 9)}; end
31
+ @revisions ||= [rev1, rev2]
28
32
  end
33
+ @doc.define_singleton_method(:trailer) { revisions.last.trailer }
29
34
  @obj = HexaPDF::Type::ObjectStream.new({N: 2, First: 8}, oid: 1, document: @doc,
30
35
  stream: "1 0 5 2 5 [1 2]")
31
36
  end
@@ -96,8 +101,9 @@ describe HexaPDF::Type::ObjectStream do
96
101
  assert_equal("", @obj.stream)
97
102
  end
98
103
 
99
- it "doesn't allow the encryption dictionary to be compressed" do
104
+ it "doesn't allow an encryption dictionary to be compressed" do
100
105
  @obj.add_object(@doc.trailer[:Encrypt])
106
+ @obj.add_object(@doc.revisions[0].trailer[:Encrypt])
101
107
  @obj.write_objects(@revision)
102
108
  assert_equal(0, @obj.value[:N])
103
109
  assert_equal(0, @obj.value[:First])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexapdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.1
4
+ version: 0.32.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2023-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse