hexapdf 0.15.1 → 0.15.2

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: 310d9fc74134cb2840118b3637c35a3037909d707532116680ef2fe6f42c43d3
4
- data.tar.gz: 76f05b220e101114d4a4136d8c07520cfe35e1e532652ea4e43593a4b812284c
3
+ metadata.gz: 1a6ef1bdd17664ef0b9474b931d31ad69c57c77928ce2b69a3bbd5dadda0dce6
4
+ data.tar.gz: 11b87436d19cc5498fd6a77f0b6c410e717809264153964668be0f5199b9354d
5
5
  SHA512:
6
- metadata.gz: 6e811e637b859f3e327ece6af28174bd6602cec0585af596c9b174127ab7276752c3e519e668757933945f2906f4a6856a96e68575eb9139f32365bfa6b8a36b
7
- data.tar.gz: 54e94c7d6704a340d1e5a5ad7b35e0715b06b6604ecec4671a079cea6049f786308258a44378280597d59e66c17e4eefd6317e94fe9a465671c2d093a7395ad3
6
+ metadata.gz: 525a55832758b5eecd1a7f2daf5f220e1afa7ff8e88ca2d65998e658585f290ff2018450e50423f2331b7f195865eab8b1c62562ecdbf3671b46d4da770aed12
7
+ data.tar.gz: 0b0e18c7f79f0e2a54080fefad1dd4d94e15157f72e5360a3ebd827fc0cc2037ae6e06302155426e7f0900e97ee0cee678e069bd8ef05a9333d684c50e1343a5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.15.2 - 2021-05-01
2
+
3
+ ### Fixed
4
+
5
+ * Handling of unencrypted metadata streams
6
+
7
+
1
8
  ## 0.15.1 - 2021-04-15
2
9
 
3
10
  ### Fixed
@@ -240,6 +240,18 @@ module HexaPDF
240
240
  end
241
241
  end
242
242
 
243
+ def decrypt(obj) #:nodoc:
244
+ if obj.type == :Metadata && obj == document.catalog.value[:Metadata] && !dict[:EncryptMetadata]
245
+ obj
246
+ else
247
+ super
248
+ end
249
+ end
250
+
251
+ def encrypt_stream(obj) #:nodoc
252
+ obj == document.catalog.value[:Metadata] && !dict[:EncryptMetadata] ? obj.stream_encoder : super
253
+ end
254
+
243
255
  private
244
256
 
245
257
  # Prepares the security handler for use in encrypting the document.
@@ -37,6 +37,6 @@
37
37
  module HexaPDF
38
38
 
39
39
  # The version of HexaPDF.
40
- VERSION = '0.15.1'
40
+ VERSION = '0.15.2'
41
41
 
42
42
  end
@@ -292,4 +292,30 @@ describe HexaPDF::Encryption::StandardSecurityHandler do
292
292
  @handler.set_up_encryption(permissions: perms)
293
293
  assert_equal([:copy_content, :modify_content], @handler.permissions.sort)
294
294
  end
295
+
296
+ describe "handling of metadata streams" do
297
+ before do
298
+ @doc = HexaPDF::Document.new
299
+ @doc.encrypt(encrypt_metadata: false)
300
+ @output = StringIO.new(''.b)
301
+ end
302
+
303
+ it "doesn't decrypt or encrypt the document level metadata stream if /EncryptMetadata is false" do
304
+ @doc.catalog[:Metadata] = @doc.wrap({Type: :Metadata, Subtype: :XML}, stream: "HELLODATA")
305
+ @doc.write(@output)
306
+ assert_match(/stream\nHELLODATA\nendstream/, @output.string)
307
+
308
+ doc = HexaPDF::Document.new(io: @output)
309
+ assert_equal('HELLODATA', doc.catalog[:Metadata].stream)
310
+ end
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")
314
+ @doc.write(@output)
315
+ refute_match(/stream\nHELLODATA\nendstream/, @output.string)
316
+
317
+ doc = HexaPDF::Document.new(io: @output)
318
+ assert_equal('HELLODATA', doc.catalog[:Anything].stream)
319
+ end
320
+ end
295
321
  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.1)>>
43
+ <</Producer(HexaPDF version 0.15.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.15.1)>>
75
+ <</Producer(HexaPDF version 0.15.2)>>
76
76
  endobj
77
77
  2 0 obj
78
78
  <</Length 10>>stream
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.15.1
4
+ version: 0.15.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: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse