hexapdf 0.15.4 → 0.15.5

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: 6901d1281fa7f0585e2fe02b27985c9b7ff26770015902566c72ea62f5398e10
4
- data.tar.gz: 4b1a82d17d4d1144b47dbb713552bb5e977896b94210a54c7b83871399d393ac
3
+ metadata.gz: 6aa5d94e3b69f1d7b2b369d248664c2c4d96d13306c1fbb1cf0960412f129faf
4
+ data.tar.gz: f6e8ae5f61de78c41fecace64d0ad5d42f8c46032e6ac6550c01b2fb43109fe8
5
5
  SHA512:
6
- metadata.gz: 1d4acb6e9f867195e998b3fd900102013a8d4b74c576f3c3243225a515bbcf2be8b62852db95cbcd9213ec06334b174fba4db406dfb8e228083d9a527eb8a5a1
7
- data.tar.gz: 3306a678655f59c35b3349cd247606ca7e45a34e033dd9b9b3bad33c20a3fda95ba07bff88acdb7c5666c23b1ab63d293963e68db7e12371c56106645df7d9bb
6
+ metadata.gz: 49f3b3aee754308956df811f564d127269e8e1dbfc613bed39e42bd77303855b80fe11c2ade362cef174838b58188470b5604e2d2c930dcf7637e7600410ac15
7
+ data.tar.gz: 3a4d5555ae6f012176aebe0a29c36500ad20f385a342c27819f5db3a0e8c5e270c58526c8434b8c8d98c59b963721a51344e93bfc6d51f3eab4fc76cceeb830e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.15.5 - 2021-07-06
2
+
3
+ ### Changed
4
+
5
+ * Refactored [HexaPDF::Tokenizer#next_xref_entry] and changed yielded value
6
+
7
+
8
+ ### Fixed
9
+
10
+ * Handling of invalid cross-reference stream entries that ends with the sequence
11
+ `\r\r`
12
+
13
+
1
14
  ## 0.15.4 - 2021-05-27
2
15
 
3
16
  ### Fixed
@@ -50,7 +50,7 @@ module HexaPDF
50
50
  module Extensions #:nodoc:
51
51
  def help_banner #:nodoc:
52
52
  "hexapdf #{HexaPDF::VERSION} - Versatile PDF Manipulation Tool\n" \
53
- "Copyright (c) 2014-2017 Thomas Leitner; licensed under the AGPLv3\n\n" \
53
+ "Copyright (c) 2014-2021 Thomas Leitner; licensed under the AGPLv3\n\n" \
54
54
  "#{format(usage, indent: 7)}\n\n"
55
55
  end
56
56
  end
@@ -263,9 +263,9 @@ module HexaPDF
263
263
 
264
264
  @tokenizer.skip_whitespace
265
265
  start.upto(start + number_of_entries - 1) do |oid|
266
- pos, gen, type = @tokenizer.next_xref_entry do |matched_size|
266
+ pos, gen, type = @tokenizer.next_xref_entry do |recoverable|
267
267
  maybe_raise("Invalid cross-reference entry", pos: @tokenizer.pos,
268
- force: !matched_size)
268
+ force: !recoverable)
269
269
  end
270
270
  if xref.entry?(oid)
271
271
  next
@@ -225,13 +225,14 @@ module HexaPDF
225
225
  # Reads the cross-reference subsection entry at the current position and advances the scan
226
226
  # pointer.
227
227
  #
228
- # If a possible problem is detected, yields to caller.
228
+ # If a problem is detected, yields to caller where the argument +recoverable+ is truthy if the
229
+ # problem is recoverable.
229
230
  #
230
231
  # See: PDF1.7 7.5.4
231
- def next_xref_entry #:yield: matched_size
232
+ def next_xref_entry #:yield: recoverable
232
233
  prepare_string_scanner(20)
233
- unless @ss.skip(/(\d{10}) (\d{5}) ([nf])(?: \r| \n|\r\n|\r|\n)/) && @ss.matched_size == 20
234
- yield(@ss.matched_size)
234
+ if !@ss.skip(/(\d{10}) (\d{5}) ([nf])(?: \r| \n|\r\n|(\r\r|\r|\n))/) || @ss[4]
235
+ yield(@ss[4])
235
236
  end
236
237
  [@ss[1].to_i, @ss[2].to_i, @ss[3]]
237
238
  end
@@ -37,6 +37,6 @@
37
37
  module HexaPDF
38
38
 
39
39
  # The version of HexaPDF.
40
- VERSION = '0.15.4'
40
+ VERSION = '0.15.5'
41
41
 
42
42
  end
@@ -210,8 +210,12 @@ module CommonTokenizerTests
210
210
 
211
211
  it "next_xref_entry: fails on invalidly formatted entries" do
212
212
  create_tokenizer("0000000001 00001 g \n")
213
- assert_raises(RuntimeError) { @tokenizer.next_xref_entry { raise } }
213
+ assert_raises(RuntimeError) { @tokenizer.next_xref_entry {|recoverable| refute(recoverable); raise } }
214
214
  create_tokenizer("0000000001 00001 n\n")
215
- assert_raises(RuntimeError) { @tokenizer.next_xref_entry { raise } }
215
+ assert_raises(RuntimeError) { @tokenizer.next_xref_entry {|recoverable| assert(recoverable); raise } }
216
+ create_tokenizer("0000000001 00001 n\r")
217
+ assert_raises(RuntimeError) { @tokenizer.next_xref_entry {|recoverable| assert(recoverable); raise } }
218
+ create_tokenizer("0000000001 00001 n\r\r")
219
+ assert_raises(RuntimeError) { @tokenizer.next_xref_entry {|recoverable| assert(recoverable); raise } }
216
220
  end
217
221
  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.4)>>
43
+ <</Producer(HexaPDF version 0.15.5)>>
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.4)>>
75
+ <</Producer(HexaPDF version 0.15.5)>>
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.4
4
+ version: 0.15.5
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-05-27 00:00:00.000000000 Z
11
+ date: 2021-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse