hexapdf 0.15.2 → 0.15.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: 1a6ef1bdd17664ef0b9474b931d31ad69c57c77928ce2b69a3bbd5dadda0dce6
4
- data.tar.gz: 11b87436d19cc5498fd6a77f0b6c410e717809264153964668be0f5199b9354d
3
+ metadata.gz: 592ea8ae7648df43e92ba50effdf3f8f34163e4acf7fb9567c3b38db46eb598e
4
+ data.tar.gz: 6c3b7d32a1499f2e2133fbafdf46b9d3cd4d1df41b9ae308c0c32ea39aefff2d
5
5
  SHA512:
6
- metadata.gz: 525a55832758b5eecd1a7f2daf5f220e1afa7ff8e88ca2d65998e658585f290ff2018450e50423f2331b7f195865eab8b1c62562ecdbf3671b46d4da770aed12
7
- data.tar.gz: 0b0e18c7f79f0e2a54080fefad1dd4d94e15157f72e5360a3ebd827fc0cc2037ae6e06302155426e7f0900e97ee0cee678e069bd8ef05a9333d684c50e1343a5
6
+ metadata.gz: fdf9edf53c0443d459008634ddbff7cd80fc1422fa558df41db04af0d9eeb512ea050d5b4a10987b824c675203e39bc851d1b2a68d0178f2cd12fada66b31245
7
+ data.tar.gz: 8e6a7b91da0ed2b63f7bc6d52c3993553f439edf986253b3508d0510310195c2a6f3721c2cfed735afc3d60dacacedc8207a6fac361bedc354bc6bd779207eac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.15.3 - 2021-05-01
2
+
3
+ ### Fixed
4
+
5
+ * Handling of general (not document-level), unencrypted metadata streams
6
+
7
+
1
8
  ## 0.15.2 - 2021-05-01
2
9
 
3
10
  ### Fixed
@@ -241,7 +241,7 @@ module HexaPDF
241
241
  end
242
242
 
243
243
  def decrypt(obj) #:nodoc:
244
- if obj.type == :Metadata && obj == document.catalog.value[:Metadata] && !dict[:EncryptMetadata]
244
+ if dict[:V] >= 4 && obj.type == :Metadata && obj[:Subtype] == :XML && !dict[:EncryptMetadata]
245
245
  obj
246
246
  else
247
247
  super
@@ -249,7 +249,11 @@ module HexaPDF
249
249
  end
250
250
 
251
251
  def encrypt_stream(obj) #:nodoc
252
- obj == document.catalog.value[:Metadata] && !dict[:EncryptMetadata] ? obj.stream_encoder : super
252
+ if dict[:V] >= 4 && obj.type == :Metadata && obj[:Subtype] == :XML && !dict[:EncryptMetadata]
253
+ obj.stream_encoder
254
+ else
255
+ super
256
+ end
253
257
  end
254
258
 
255
259
  private
@@ -37,6 +37,6 @@
37
37
  module HexaPDF
38
38
 
39
39
  # The version of HexaPDF.
40
- VERSION = '0.15.2'
40
+ VERSION = '0.15.3'
41
41
 
42
42
  end
@@ -296,11 +296,11 @@ describe HexaPDF::Encryption::StandardSecurityHandler do
296
296
  describe "handling of metadata streams" do
297
297
  before do
298
298
  @doc = HexaPDF::Document.new
299
- @doc.encrypt(encrypt_metadata: false)
300
299
  @output = StringIO.new(''.b)
301
300
  end
302
301
 
303
- it "doesn't decrypt or encrypt the document level metadata stream if /EncryptMetadata is false" do
302
+ it "doesn't decrypt or encrypt a metadata stream if /EncryptMetadata is false" do
303
+ @doc.encrypt(encrypt_metadata: false)
304
304
  @doc.catalog[:Metadata] = @doc.wrap({Type: :Metadata, Subtype: :XML}, stream: "HELLODATA")
305
305
  @doc.write(@output)
306
306
  assert_match(/stream\nHELLODATA\nendstream/, @output.string)
@@ -309,13 +309,14 @@ describe HexaPDF::Encryption::StandardSecurityHandler do
309
309
  assert_equal('HELLODATA', doc.catalog[:Metadata].stream)
310
310
  end
311
311
 
312
- it "doesn't modify decryption/encryption for arbitrary metadata streams" do
313
- @doc.catalog[:Anything] = @doc.wrap({Type: :Metadata, Subtype: :XML}, stream: "HELLODATA")
312
+ it "doesn't modify decryption/encryption for metadata streams if /V is not 4 or 5" do
313
+ @doc.encrypt(encrypt_metadata: false, algorithm: :arc4)
314
+ @doc.catalog[:Metadata] = @doc.wrap({Type: :Metadata, Subtype: :XML}, stream: "HELLODATA")
314
315
  @doc.write(@output)
315
316
  refute_match(/stream\nHELLODATA\nendstream/, @output.string)
316
317
 
317
318
  doc = HexaPDF::Document.new(io: @output)
318
- assert_equal('HELLODATA', doc.catalog[:Anything].stream)
319
+ assert_equal('HELLODATA', doc.catalog[:Metadata].stream)
319
320
  end
320
321
  end
321
322
  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.15.2)>>
43
+ <</Producer(HexaPDF version 0.15.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.15.2)>>
75
+ <</Producer(HexaPDF version 0.15.3)>>
76
76
  endobj
77
77
  2 0 obj
78
78
  <</Length 10>>stream
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexapdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner