hexapdf 0.9.2 → 0.9.3

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: ee462224ffa152978df2a0aebd05b52c7a75a21655880858bbb4b61e2eccd3dd
4
- data.tar.gz: dc2eedf3a556c7a85fbfb229372512043f33200c6ffb6223b344c96bf4aff91b
3
+ metadata.gz: a1011a745720b76eaa963d0a54b6807e732fe6ecd3bcb029870309e42296bbe9
4
+ data.tar.gz: 0aed16b283825785a7039ebca11a61da853c7fb01e8d2fadc9e5d7a722e56754
5
5
  SHA512:
6
- metadata.gz: da87ec95143ad653a606c699dc4e29ac3e4abf6b4e1a0bfc535ede8221f047ab35f7b69556eaa7b7cf23d7da69909685c515d98ea67f1e1e0265ebbb460f2eb7
7
- data.tar.gz: f47ec5e10af27baf8a8ee06d4f496f53841b57acc93ce1111288576a473dfb73d73052aa65f21835e19ebadb6e87868fcc3d63f84c82dbfd81dca7ae56eb9975
6
+ metadata.gz: 70bee8b172f67ab59559ec1b0d740d767dad0db0a5d30476bdbfd71f80f443b31fc8b98bfd62a6d632411c246aa04af9c4203c443f4affc7b0307694bd5b725b
7
+ data.tar.gz: 04002b0d6728a37c499c1453a4068161b6c3c2631e318981559e52207681ae268de39b6a5b9127b39ee009be079c06e8ea761c2633d1f586efb0294a923e7a61
@@ -1,3 +1,15 @@
1
+ ## 0.9.3 - 2019-06-13
2
+
3
+ ### Changed
4
+
5
+ * Behaviour of how object streams are generated to work around a bug (?) in
6
+ Adobe Acrobat
7
+
8
+ ### Fixed
9
+
10
+ * Fix problem with [HexaPDF::Encryption::StandardSecurityHandler] due to
11
+ behaviour change of Ruby 2.6.0 in `String#setbyte`
12
+
1
13
  ## 0.9.2 - 2019-05-22
2
14
 
3
15
  ### Changed
@@ -1,4 +1,4 @@
1
1
  Count Name
2
2
  ======= ====
3
- 1037 Thomas Leitner <t_leitner@gmx.at>
3
+ 1041 Thomas Leitner <t_leitner@gmx.at>
4
4
  1 Daniel Kraus <bovender@bovender.de>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
@@ -607,7 +607,7 @@ module HexaPDF
607
607
  new_key = key.dup
608
608
  i = 0
609
609
  while i < new_key.length
610
- new_key.setbyte(i, new_key.getbyte(i) ^ value)
610
+ new_key.setbyte(i, (new_key.getbyte(i) ^ value) % 256)
611
611
  i += 1
612
612
  end
613
613
  new_key
@@ -174,7 +174,11 @@ module HexaPDF
174
174
  encrypt_dict = document.trailer[:Encrypt]
175
175
  while index < objects.size / 2
176
176
  obj = revision.object(objects[index])
177
- if obj.nil? || obj.null? || obj.gen != 0 || obj.kind_of?(Stream) || obj == encrypt_dict
177
+
178
+ # Due to a bug in Adobe Acrobat, the Catalog may not be in an object stream if the
179
+ # document is encrypted
180
+ if obj.nil? || obj.null? || obj.gen != 0 || obj.kind_of?(Stream) || obj == encrypt_dict ||
181
+ (encrypt_dict && obj.type == :Catalog)
178
182
  delete_object(objects[index])
179
183
  next
180
184
  end
@@ -37,6 +37,6 @@
37
37
  module HexaPDF
38
38
 
39
39
  # The version of HexaPDF.
40
- VERSION = '0.9.2'
40
+ VERSION = '0.9.3'
41
41
 
42
42
  end
@@ -40,7 +40,7 @@ describe HexaPDF::Writer do
40
40
  219
41
41
  %%EOF
42
42
  3 0 obj
43
- <</Producer(HexaPDF version 0.9.2)>>
43
+ <</Producer(HexaPDF version 0.9.3)>>
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.9.2)>>
75
+ <</Producer(HexaPDF version 0.9.3)>>
76
76
  endobj
77
77
  2 0 obj
78
78
  <</Length 10>>stream
@@ -57,21 +57,53 @@ describe HexaPDF::Type::ObjectStream do
57
57
  assert_nil(@obj.object_index(5))
58
58
  end
59
59
 
60
- it "allows writing the objects to the stream" do
61
- @obj.stream = 'something'
62
- @obj.add_object(HexaPDF::Object.new(5, oid: 1))
63
- @obj.add_object(HexaPDF::Object.new(:will_be_deleted, oid: 3, gen: 1))
64
- @obj.add_object(HexaPDF::Object.new([1, 2], oid: 5))
65
- @obj.add_object(HexaPDF::Object.new(nil, oid: 7))
66
- @obj.add_object(@doc.trailer[:Encrypt])
67
-
68
- revision = Object.new
69
- def revision.object(obj); obj; end
70
- @obj.write_objects(revision)
71
-
72
- assert_equal(2, @obj.value[:N])
73
- assert_equal(8, @obj.value[:First])
74
- assert_equal("1 0 5 2 5 [1 2] ", @obj.stream)
60
+ describe "write objects to stream" do
61
+ before do
62
+ @revision = Object.new
63
+ def @revision.object(obj); obj; end
64
+ end
65
+
66
+ it "processes allowed objects" do
67
+ @obj.add_object(HexaPDF::Object.new(5, oid: 1))
68
+ @obj.add_object(HexaPDF::Object.new([1, 2], oid: 5))
69
+
70
+ @obj.write_objects(@revision)
71
+ assert_equal(2, @obj.value[:N])
72
+ assert_equal(8, @obj.value[:First])
73
+ assert_equal("1 0 5 2 5 [1 2] ", @obj.stream)
74
+ end
75
+
76
+ it "doesn't allow null objects" do
77
+ @obj.add_object(HexaPDF::Object.new(nil, oid: 7))
78
+ @obj.write_objects(@revision)
79
+ assert_equal(0, @obj.value[:N])
80
+ assert_equal(0, @obj.value[:First])
81
+ assert_equal("", @obj.stream)
82
+ end
83
+
84
+ it "doesn't allow objects with gen not 0" do
85
+ @obj.add_object(HexaPDF::Object.new(:will_be_deleted, oid: 3, gen: 1))
86
+ @obj.write_objects(@revision)
87
+ assert_equal(0, @obj.value[:N])
88
+ assert_equal(0, @obj.value[:First])
89
+ assert_equal("", @obj.stream)
90
+ end
91
+
92
+ it "doesn't allow the encryption dictionary to be compressed" do
93
+ @obj.add_object(@doc.trailer[:Encrypt])
94
+ @obj.write_objects(@revision)
95
+ assert_equal(0, @obj.value[:N])
96
+ assert_equal(0, @obj.value[:First])
97
+ assert_equal("", @obj.stream)
98
+ end
99
+
100
+ it "doesn't allow the Catalog entry to be compressed when encryption is used" do
101
+ @obj.add_object(HexaPDF::Dictionary.new({Type: :Catalog}, oid: 8))
102
+ @obj.write_objects(@revision)
103
+ assert_equal(0, @obj.value[:N])
104
+ assert_equal(0, @obj.value[:First])
105
+ assert_equal("", @obj.stream)
106
+ end
75
107
  end
76
108
 
77
109
  it "fails validation if gen != 0" do
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.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse