origamindee 4.0.1 → 4.0.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: 32d41a9349494b6e39a1246a23210b1abbadfedc09ac68159246bfc3b6b1dd5d
4
- data.tar.gz: ffd6de36aac285129fb1cf9cc6e4c2bf6db71673cd3f011edca5ad3e540128bf
3
+ metadata.gz: 23fc6786be96ca2e6f3047722fd4bfb09324f0238ce8a9f5be88a33b6cb1f2df
4
+ data.tar.gz: a278ca888d67920f8db2f2318b7ac34498f6e5bf14dcd9388ebef6493ef9ee16
5
5
  SHA512:
6
- metadata.gz: e8ed213496ec09d46e9ac1a28eb8cb37b7dd6990d880093eaed158ff569d8350a09610a769561a42a0213929a3731a15834ed2175b40403f1ef35b5785a9a566
7
- data.tar.gz: 1905e3c2983003116b3657db7b373b77ff8ee53c6b62f67ca381106081ebbb70ce60cd4de6bea06138ea7256c449b757932b72aaaf061b2b6d971a16ce09e057
6
+ metadata.gz: 512e0cfb05f947a5ee902f7488cfdc6d94661a07d46522c02ba89e73376d18d4ffe7e3e3af7409077960b45bae7fbadd41cf7c226d589c9ad4e762a515674473
7
+ data.tar.gz: dd68ed8a3dda6df42556c786f6c4027bae54a814d9bb4339ef0e5cefad66963fa5f481d63e9d58b0ac1b5e0c40d2eac0307185597f98487b459ce2a83411e3ae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 4.0.2
2
+ -----
3
+ * Fix improper parsing of nametree leaves
4
+ * Fix string frozen literal warnings for ruby >= 3.4
5
+
6
+
1
7
  4.0.1
2
8
  -----
3
9
  * Update dependencies & loosen version constraints
data/bin/pdf2ruby CHANGED
@@ -90,7 +90,7 @@ TARGET_FILE = File.join(TARGET_DIR, "#{TARGET_DIR}.rb")
90
90
  STREAM_DIR = "streams"
91
91
 
92
92
  def objectToRuby(obj, inclevel = 0, internalname = nil, do_convert = false)
93
- code = ""
93
+ code = ::String.new
94
94
 
95
95
  code <<
96
96
  case obj
data/bin/pdfcop CHANGED
@@ -171,7 +171,7 @@ end
171
171
  def analyze_xfa_forms(xfa)
172
172
  case xfa
173
173
  when Origami::Array then
174
- xml = ""
174
+ xml = ::String.new
175
175
  i = 0
176
176
  xfa.each do |packet|
177
177
  if i % 2 == 1
data/bin/pdfextract CHANGED
@@ -171,7 +171,7 @@ begin
171
171
 
172
172
  case xfa
173
173
  when Array then
174
- xml = ""
174
+ xml = ::String.new
175
175
  i = 0
176
176
  xfa.each do |packet|
177
177
  if i % 2 == 1
data/bin/shell/hexdump.rb CHANGED
@@ -23,14 +23,14 @@ require 'colorize'
23
23
  class String #:nodoc:
24
24
 
25
25
  def hexdump(bytesperline: 16, upcase: true, offsets: true, delta: 0)
26
- dump = ""
26
+ dump = ::String.new
27
27
  counter = 0
28
28
 
29
29
  while counter < self.length
30
30
  offset = sprintf("%010X", counter + delta)
31
31
 
32
32
  linelen = [ self.length - counter, bytesperline ].min
33
- bytes = ""
33
+ bytes = ::String.new
34
34
  linelen.times do |i|
35
35
  byte = self[counter + i].ord.to_s(16).rjust(2, '0')
36
36
 
@@ -20,7 +20,7 @@ OUTPUT_FILE = "#{File.basename(__FILE__, ".rb")}.pdf"
20
20
  # XDP Packet holding the Form.
21
21
  #
22
22
  class SampleXDP < XDP::Package
23
- def initialize(script = "")
23
+ def initialize(script = ::String.new)
24
24
  super()
25
25
 
26
26
  self.root.add_element(create_config_packet)
data/lib/origami/array.rb CHANGED
@@ -196,8 +196,17 @@ module Origami
196
196
  next
197
197
  end
198
198
 
199
- unless object_value.is_a?(index_type)
200
- STDERR.puts "Warning: object #{self.class.name || 'Array'} should be composed of #{index_type.name} at index #{index} (got #{object_value.type} instead)"
199
+ valid_type = case index_type
200
+ when Class
201
+ object_value.is_a?(index_type)
202
+ when Array
203
+ index_type.any? { |type| object_value.is_a?(type) }
204
+ else
205
+ true
206
+ end
207
+ unless valid_type
208
+ allowed = Array(index_type).map(&:name).join('|')
209
+ STDERR.puts "Warning: object #{self.class.name} should be one of [#{allowed}] at index #{index} (got #{object_value.type} instead)"
201
210
  end
202
211
  end
203
212
  end
@@ -47,7 +47,7 @@ module Origami
47
47
  # Decrypts the current document.
48
48
  # _passwd_:: The password to decrypt the document.
49
49
  #
50
- def decrypt(passwd = "")
50
+ def decrypt(passwd = ::String.new)
51
51
  raise EncryptionError, "PDF is not encrypted" unless self.encrypted?
52
52
 
53
53
  # Turn the encryption dictionary into a standard encryption dictionary.
@@ -269,7 +269,7 @@ module Origami
269
269
  end
270
270
 
271
271
  def save(path)
272
- bin = "".b
272
+ bin = ::String.new.b
273
273
  bin << @header.to_s
274
274
 
275
275
  lastno, brange = 0, 0
@@ -264,7 +264,7 @@ module Origami
264
264
  end
265
265
 
266
266
  def save(path)
267
- bin = "".b
267
+ bin = ::String.new.b
268
268
  bin << @header.to_s
269
269
 
270
270
  lastno, brange = 0, 0
@@ -102,7 +102,7 @@ module Origami
102
102
  # Converts Windows file path into PDF file path.
103
103
  #
104
104
  def DOS(file)
105
- path = ""
105
+ path = ::String.new
106
106
  # Absolute vs relative path
107
107
  if file.include? ":"
108
108
  path << "/"
@@ -79,7 +79,7 @@ module Origami
79
79
  #
80
80
  def encode(stream)
81
81
  i = 0
82
- code = "".b
82
+ code = ::String.new.b
83
83
  input = stream.dup
84
84
 
85
85
  while i < input.size do
@@ -121,7 +121,7 @@ module Origami
121
121
 
122
122
  while i < input.size
123
123
 
124
- outblock = ""
124
+ outblock = ::String.new
125
125
  value = 0
126
126
  addend = 0
127
127
 
@@ -169,7 +169,7 @@ module Origami
169
169
  # Encodes an integer value into an ASCII85 block of 5 characters.
170
170
  #
171
171
  def encode_block(value)
172
- block = "".b
172
+ block = ::String.new.b
173
173
 
174
174
  5.times do |p|
175
175
  c = value / 85 ** (4 - p)
@@ -80,7 +80,7 @@ module Origami
80
80
  # _stream_:: The data to decode.
81
81
  #
82
82
  def decode(string)
83
- result = "".b
83
+ result = ::String.new.b
84
84
  bstring = Utils::BitReader.new(string)
85
85
  table, codesize = reset_state
86
86
  prevbyte = nil
@@ -143,7 +143,7 @@ module Origami
143
143
  # Each line should be prepended by a byte identifying a PNG predictor.
144
144
  #
145
145
  def png_post_prediction(data, bpp, bpr)
146
- result = ""
146
+ result = ::String.new
147
147
  uprow = "\0" * bpr
148
148
  thisrow = "\0" * bpr
149
149
  nrows = (data.size + bpr - 1) / bpr
@@ -185,7 +185,7 @@ module Origami
185
185
  # Encodes the input data given a PNG predictor.
186
186
  #
187
187
  def png_pre_prediction(data, predictor, bpp, bpr)
188
- result = ""
188
+ result = ::String.new
189
189
  nrows = data.size / bpr
190
190
 
191
191
  line = "\0" + data[-bpr, bpr]
@@ -38,7 +38,7 @@ module Origami
38
38
  # _stream_:: The data to encode.
39
39
  #
40
40
  def encode(stream)
41
- result = "".b
41
+ result = ::String.new.b
42
42
  i = 0
43
43
 
44
44
  while i < stream.size
@@ -70,7 +70,7 @@ module Origami
70
70
  # _stream_:: The data to decode.
71
71
  #
72
72
  def decode(stream)
73
- result = "".b
73
+ result = ::String.new.b
74
74
 
75
75
  i = 0
76
76
  until i >= stream.length or stream[i].ord == EOD do
@@ -37,7 +37,7 @@ module Origami
37
37
 
38
38
  attr_accessor :canvas
39
39
 
40
- def initialize(data = "", dictionary = {})
40
+ def initialize(data = ::String.new, dictionary = {})
41
41
  super
42
42
 
43
43
  @instructions = nil
@@ -808,7 +808,7 @@ module Origami
808
808
  end
809
809
 
810
810
  raise InvalidColorError, "Invalid base color space" unless cs_base
811
- palette = ""
811
+ palette = ::String.new
812
812
 
813
813
  case cs_base
814
814
  when Color::Space::DEVICE_GRAY
@@ -179,7 +179,7 @@ module Origami
179
179
  end
180
180
 
181
181
  def to_s
182
- data = ""
182
+ data = ::String.new
183
183
 
184
184
  nitems = self.class.nb_header_items
185
185
  for no in (1..nitems)
@@ -300,7 +300,7 @@ module Origami
300
300
  raise InvalidHintStreamObjectError, "No shared objects hint table"
301
301
  end
302
302
 
303
- @data = ""
303
+ @data = ::String.new
304
304
  save_table(@page_offset_table)
305
305
  save_table(@shared_objects_table, :S)
306
306
  save_table(@thumbnails_table, :T)
@@ -114,7 +114,7 @@ module Origami
114
114
  desc.elements << elt
115
115
  end
116
116
 
117
- xml = ""; doc.write(xml, 4)
117
+ xml = ::String.new; doc.write(xml, 4)
118
118
 
119
119
  if self.Catalog.Metadata.is_a?(Stream)
120
120
  self.Catalog.Metadata.data = xml
data/lib/origami/name.rb CHANGED
@@ -41,7 +41,7 @@ module Origami
41
41
  # Creates a new Name.
42
42
  # _name_:: A symbol representing the new Name value.
43
43
  #
44
- def initialize(name = "")
44
+ def initialize(name = ::String.new)
45
45
  unless name.is_a?(Symbol) or name.is_a?(::String)
46
46
  raise TypeError, "Expected type Symbol or String, received #{name.class}."
47
47
  end
@@ -218,7 +218,7 @@ module Origami
218
218
 
219
219
  class Stream
220
220
  def to_obfuscated_str
221
- content = ""
221
+ content = ::String.new
222
222
 
223
223
  content << @dictionary.to_obfuscated_str
224
224
  content << "stream" + $/
@@ -231,7 +231,7 @@ module Origami
231
231
 
232
232
  class Trailer
233
233
  def to_obfuscated_str
234
- content = ""
234
+ content = ::String.new
235
235
  if self.dictionary?
236
236
  content << TOKENS.first << $/ << @dictionary.to_obfuscated_str << $/
237
237
  end
@@ -689,8 +689,8 @@ module Origami
689
689
  # _data_:: The object data.
690
690
  #
691
691
  def to_s(data, eol: $/)
692
- content = ""
693
- content << "#{no} #{generation} #{TOKENS.first}" << eol if indirect? and numbered?
692
+ content = ::String.new
693
+ content << "#{no} #{generation} #{TOKENS.first}".dup << eol if indirect? and numbered?
694
694
  content << data
695
695
  content << eol << TOKENS.last << eol if indirect? and numbered?
696
696
 
@@ -77,7 +77,7 @@ module Origami
77
77
  desc.add REXML::Element.new('pdfaid:part').add_text('1')
78
78
  doc.elements["*/rdf:RDF"].add desc
79
79
 
80
- xml = ""; doc.write(xml, 3)
80
+ xml = ::String.new; doc.write(xml, 3)
81
81
  metadata.data = xml
82
82
  end
83
83
  end
@@ -188,23 +188,23 @@ module Origami
188
188
  @data.string.dup if @data
189
189
  end
190
190
 
191
- def error(msg = "") #:nodoc:
191
+ def error(msg = ::String.new) #:nodoc:
192
192
  log(VERBOSE_QUIET, 'error', :red, msg)
193
193
  end
194
194
 
195
- def warn(msg = "") #:nodoc:
195
+ def warn(msg = ::String.new) #:nodoc:
196
196
  log(VERBOSE_INFO, 'warn ', :yellow, msg)
197
197
  end
198
198
 
199
- def info(msg = "") #:nodoc:
199
+ def info(msg = ::String.new) #:nodoc:
200
200
  log(VERBOSE_INFO, 'info ', :green, msg)
201
201
  end
202
202
 
203
- def debug(msg = "") #:nodoc:
203
+ def debug(msg = ::String.new) #:nodoc:
204
204
  log(VERBOSE_DEBUG, 'debug', :magenta, msg)
205
205
  end
206
206
 
207
- def trace(msg = "") #:nodoc:
207
+ def trace(msg = ::String.new) #:nodoc:
208
208
  log(VERBOSE_TRACE, 'trace', :cyan, msg)
209
209
  end
210
210
 
data/lib/origami/pdf.rb CHANGED
@@ -824,7 +824,7 @@ module Origami
824
824
  xrefstm_offset = nil
825
825
 
826
826
  # Header
827
- bin = ""
827
+ bin = ::String.new
828
828
  bin << @header.to_s(eol: options[:eol])
829
829
 
830
830
  # For each revision
@@ -84,7 +84,7 @@ module Origami
84
84
  # _data_:: The Stream uncompressed data.
85
85
  # _dictionary_:: A hash representing the Stream attributes.
86
86
  #
87
- def initialize(data = "", dictionary = {})
87
+ def initialize(data = ::String.new, dictionary = {})
88
88
  super()
89
89
 
90
90
  set_indirect(true)
@@ -334,7 +334,7 @@ module Origami
334
334
  end
335
335
 
336
336
  def to_s(indent: 1, tab: "\t", eol: $/) #:nodoc:
337
- content = ""
337
+ content = ::String.new
338
338
 
339
339
  content << @dictionary.to_s(indent: indent, tab: tab)
340
340
  content << "stream" + eol
@@ -485,7 +485,7 @@ module Origami
485
485
  # _dictionary_:: A hash of attributes to set to the Stream.
486
486
  # _raw_data_:: The Stream data.
487
487
  #
488
- def initialize(raw_data = "", dictionary = {})
488
+ def initialize(raw_data = ::String.new, dictionary = {})
489
489
  super
490
490
 
491
491
  @objects = nil
@@ -494,8 +494,8 @@ module Origami
494
494
  def pre_build #:nodoc:
495
495
  load!
496
496
 
497
- prolog = ""
498
- data = ""
497
+ prolog = ::String.new
498
+ data = ::String.new
499
499
  objoff = 0
500
500
  @objects.to_a.sort.each do |num,obj|
501
501
 
@@ -110,7 +110,7 @@ module Origami
110
110
  attr_accessor :encoding
111
111
 
112
112
  def initialize(str) #:nodoc:
113
- super(str.force_encoding('binary'))
113
+ super(str.b)
114
114
 
115
115
  detect_encoding
116
116
  end
@@ -170,7 +170,7 @@ module Origami
170
170
  # Creates a new PDF hexadecimal String.
171
171
  # _str_:: The string value.
172
172
  #
173
- def initialize(str = "")
173
+ def initialize(str = ::String.new)
174
174
  unless str.is_a?(::String)
175
175
  raise TypeError, "Expected type String, received #{str.class}."
176
176
  end
@@ -239,7 +239,7 @@ module Origami
239
239
  # Creates a new PDF String.
240
240
  # _str_:: The string value.
241
241
  #
242
- def initialize(str = "")
242
+ def initialize(str = ::String.new)
243
243
  unless str.is_a?(::String)
244
244
  raise TypeError, "Expected type String, received #{str.class}."
245
245
  end
@@ -255,7 +255,7 @@ module Origami
255
255
  raise InvalidLiteralStringObjectError, "No literal string start token found"
256
256
  end
257
257
 
258
- result = ""
258
+ result = ::String.new
259
259
  depth = 0
260
260
  while depth != 0 or scanner.peek(1) != TOKENS.last do
261
261
  raise InvalidLiteralStringObjectError, "Non-terminated string" if scanner.eos?
@@ -176,7 +176,7 @@ module Origami
176
176
  # Outputs self into PDF code.
177
177
  #
178
178
  def to_s(indent: 1, eol: $/)
179
- content = ""
179
+ content = ::String.new
180
180
  if self.dictionary?
181
181
  content << TOKENS.first << eol << @dictionary.to_s(indent: indent, eol: eol) << eol
182
182
  end
@@ -21,5 +21,5 @@
21
21
  =end
22
22
 
23
23
  module Origami
24
- VERSION = '4.0.1'
24
+ VERSION = '4.0.2'
25
25
  end
@@ -44,7 +44,7 @@ module Origami
44
44
  end
45
45
 
46
46
  class URI < XFA::ConfigElement
47
- def initialize(uri = "")
47
+ def initialize(uri = ::String.new)
48
48
  super('uri')
49
49
 
50
50
  self.text = uri
@@ -91,7 +91,7 @@ module Origami
91
91
  end
92
92
 
93
93
  class Locale < XFA::ConfigElement
94
- def initialize(locale = "")
94
+ def initialize(locale = ::String.new)
95
95
  super('locale')
96
96
 
97
97
  self.text = locale
@@ -99,7 +99,7 @@ module Origami
99
99
  end
100
100
 
101
101
  class LocaleSet < XFA::ConfigElement
102
- def initialize(uri = "")
102
+ def initialize(uri = ::String.new)
103
103
  super('localeSet')
104
104
 
105
105
  self.text = uri
@@ -115,7 +115,7 @@ module Origami
115
115
  end
116
116
 
117
117
  class Range < XFA::ConfigElement
118
- def initialize(range = "")
118
+ def initialize(range = ::String.new)
119
119
  super('range')
120
120
 
121
121
  self.text = range
@@ -123,7 +123,7 @@ module Origami
123
123
  end
124
124
 
125
125
  class Record < XFA::ConfigElement
126
- def initialize(record = "")
126
+ def initialize(record = ::String.new)
127
127
  super('record')
128
128
 
129
129
  self.text = record
@@ -131,7 +131,7 @@ module Origami
131
131
  end
132
132
 
133
133
  class StartNode < XFA::ConfigElement
134
- def initialize(somexpr = "")
134
+ def initialize(somexpr = ::String.new)
135
135
  super('startNode')
136
136
 
137
137
  self.text = somexpr
@@ -156,7 +156,7 @@ module Origami
156
156
  end
157
157
 
158
158
  class ExcludeNS < XFA::ConfigElement
159
- def initialize(ns = "")
159
+ def initialize(ns = ::String.new)
160
160
  super('excludeNS')
161
161
 
162
162
  self.text = ns
@@ -164,7 +164,7 @@ module Origami
164
164
  end
165
165
 
166
166
  class GroupParent < XFA::ConfigElement
167
- def initialize(parentname = "")
167
+ def initialize(parentname = ::String.new)
168
168
  super('groupParent')
169
169
 
170
170
  self.text = parentname
@@ -193,7 +193,7 @@ module Origami
193
193
  end
194
194
 
195
195
  class Picture < XFA::ConfigElement
196
- def initialize(clause = "")
196
+ def initialize(clause = ::String.new)
197
197
  super('picture')
198
198
 
199
199
  self.text = clause
@@ -215,7 +215,7 @@ module Origami
215
215
  end
216
216
 
217
217
  class Rename < XFA::ConfigElement
218
- def initialize(nodename = "")
218
+ def initialize(nodename = ::String.new)
219
219
  super('rename')
220
220
 
221
221
  self.text = nodename
@@ -319,7 +319,7 @@ module Origami
319
319
  end
320
320
 
321
321
  class Base < XFA::ConfigElement
322
- def initialize(uri = "")
322
+ def initialize(uri = ::String.new)
323
323
  super('base')
324
324
 
325
325
  self.text = uri
@@ -327,7 +327,7 @@ module Origami
327
327
  end
328
328
 
329
329
  class Relevant < XFA::ConfigElement
330
- def initialize(token = "")
330
+ def initialize(token = ::String.new)
331
331
  super('relevant')
332
332
 
333
333
  self.text = token
@@ -59,7 +59,7 @@ module Origami
59
59
  xfa_attribute 'input'
60
60
  xfa_attribute 'output'
61
61
 
62
- def initialize(name = "")
62
+ def initialize(name = ::String.new)
63
63
  super('operation')
64
64
 
65
65
  self.text = name
@@ -67,7 +67,7 @@ module Origami
67
67
  end
68
68
 
69
69
  class SOAPAction < XFA::NamedTemplateElement
70
- def initialize(uri = "")
70
+ def initialize(uri = ::String.new)
71
71
  super('soapAction')
72
72
 
73
73
  self.text = uri
@@ -75,7 +75,7 @@ module Origami
75
75
  end
76
76
 
77
77
  class SOAPAddress < XFA::NamedTemplateElement
78
- def initialize(addr = "")
78
+ def initialize(addr = ::String.new)
79
79
  super('soapAddress')
80
80
 
81
81
  self.text = addr
@@ -83,7 +83,7 @@ module Origami
83
83
  end
84
84
 
85
85
  class WSDLAddress < XFA::NamedTemplateElement
86
- def initialize(addr = "")
86
+ def initialize(addr = ::String.new)
87
87
  super('wsdlAddress')
88
88
 
89
89
  self.text = addr
@@ -104,7 +104,7 @@ module Origami
104
104
  end
105
105
 
106
106
  class URI < XFA::NamedTemplateElement
107
- def initialize(uri = "")
107
+ def initialize(uri = ::String.new)
108
108
  super('uri')
109
109
 
110
110
  self.text = uri
@@ -115,7 +115,7 @@ module Origami
115
115
  xfa_attribute 'maxChars'
116
116
  xfa_attribute 'rid'
117
117
 
118
- def initialize(text = "")
118
+ def initialize(text = ::String.new)
119
119
  super('text')
120
120
 
121
121
  self.text = text
@@ -153,7 +153,7 @@ module Origami
153
153
  xfa_attribute 'priority'
154
154
  xfa_attribute 'rid'
155
155
 
156
- def initialize(text = "")
156
+ def initialize(text = ::String.new)
157
157
  super('speak')
158
158
 
159
159
  self.text = text
@@ -163,7 +163,7 @@ module Origami
163
163
  class ToolTip < XFA::TemplateElement
164
164
  xfa_attribute 'rid'
165
165
 
166
- def initialize(text = "")
166
+ def initialize(text = ::String.new)
167
167
  super('toolTip')
168
168
 
169
169
  self.text = text
@@ -382,7 +382,7 @@ module Origami
382
382
  xfa_attribute 'contentType'
383
383
  xfa_attribute 'runAt'
384
384
 
385
- def initialize(script = "")
385
+ def initialize(script = ::String.new)
386
386
  super('script')
387
387
 
388
388
  self.text = script
@@ -390,7 +390,7 @@ module Origami
390
390
  end
391
391
 
392
392
  class JavaScript < Script
393
- def initialize(script = "")
393
+ def initialize(script = ::String.new)
394
394
  super(script)
395
395
 
396
396
  self.contentType = 'application/x-javascript'
@@ -398,7 +398,7 @@ module Origami
398
398
  end
399
399
 
400
400
  class FormCalcScript < Script
401
- def initialize(script = "")
401
+ def initialize(script = ::String.new)
402
402
  super(script)
403
403
 
404
404
  self.contentType = 'application/x-formcalc'
@@ -797,7 +797,7 @@ module Origami
797
797
  class AppearanceFilter < XFA::TemplateElement
798
798
  xfa_attribute 'type'
799
799
 
800
- def initialize(name = "")
800
+ def initialize(name = ::String.new)
801
801
  super('appearanceFilter')
802
802
 
803
803
  self.text = name
@@ -832,7 +832,7 @@ module Origami
832
832
  end
833
833
 
834
834
  class OID < XFA::NamedTemplateElement
835
- def initialize(oid = "")
835
+ def initialize(oid = ::String.new)
836
836
  super('oid')
837
837
 
838
838
  self.text = oid
@@ -862,7 +862,7 @@ module Origami
862
862
  class SubjectDN < XFA::NamedTemplateElement
863
863
  xfa_attribute 'delimiter'
864
864
 
865
- def initialize(data = "")
865
+ def initialize(data = ::String.new)
866
866
  super('subjectDN')
867
867
 
868
868
  self.text = data
@@ -896,7 +896,7 @@ module Origami
896
896
  end
897
897
 
898
898
  class DigestMethod < XFA::TemplateElement
899
- def initialize(method = "")
899
+ def initialize(method = ::String.new)
900
900
  super('digestMethod')
901
901
 
902
902
  self.text = method
@@ -914,7 +914,7 @@ module Origami
914
914
  end
915
915
 
916
916
  class Encoding < XFA::TemplateElement
917
- def initialize(encoding = "")
917
+ def initialize(encoding = ::String.new)
918
918
  super('encoding')
919
919
 
920
920
  self.text = encoding
@@ -934,7 +934,7 @@ module Origami
934
934
  class Handler < XFA::TemplateElement
935
935
  xfa_attribute 'type'
936
936
 
937
- def initialize(handler = "")
937
+ def initialize(handler = ::String.new)
938
938
  super('handler')
939
939
 
940
940
  self.text = handler
@@ -961,7 +961,7 @@ module Origami
961
961
  end
962
962
 
963
963
  class Reason < XFA::NamedTemplateElement
964
- def initialize(reason = "")
964
+ def initialize(reason = ::String.new)
965
965
  super('reason')
966
966
 
967
967
  self.text = reason
@@ -335,13 +335,13 @@ module Origami
335
335
  # Outputs self into PDF code.
336
336
  #
337
337
  def to_s(eol: $/)
338
- "xref" << eol << @subsections.map{|sub| sub.to_s(eol: eol)}.join
338
+ "xref".dup << eol << @subsections.map{|sub| sub.to_s(eol: eol)}.join
339
339
  end
340
340
  end
341
341
  end
342
342
 
343
343
  #
344
- # An xref poiting to an Object embedded in an ObjectStream.
344
+ # An xref pointing to an Object embedded in an ObjectStream.
345
345
  #
346
346
  class XRefToCompressedObject
347
347
  attr_accessor :objstmno, :index
@@ -397,7 +397,7 @@ module Origami
397
397
  field :Info, :Type => Metadata
398
398
  field :ID, :Type => Array.of(String, length: 2)
399
399
 
400
- def initialize(data = "", dictionary = {})
400
+ def initialize(data = ::String.new, dictionary = {})
401
401
  super(data, dictionary)
402
402
 
403
403
  @xrefs = nil
@@ -532,7 +532,7 @@ module Origami
532
532
  end
533
533
 
534
534
  def save! #:nodoc:
535
- self.data = ""
535
+ self.data = ::String.new
536
536
 
537
537
  type_w, field1_w, field2_w = self.W
538
538
  @xrefs.each do |xref| @data << xref.to_xrefstm_data(type_w, field1_w, field2_w) end
@@ -0,0 +1,65 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ <<
5
+ /Type /Pages
6
+ /Count 1
7
+ /Kids [ 4 0 R ]
8
+ >>
9
+ endobj
10
+ 2 0 obj
11
+ <<
12
+ /Producer (PyPDF2)
13
+ >>
14
+ endobj
15
+ 3 0 obj
16
+ <<
17
+ /Type /Catalog
18
+ /Pages 1 0 R
19
+ /Names 6 0 R
20
+ >>
21
+ endobj
22
+ 4 0 obj
23
+ <<
24
+ /Type /Page
25
+ /Resources <<
26
+ >>
27
+ /MediaBox [ 0 0 612 792 ]
28
+ /Parent 1 0 R
29
+ >>
30
+ endobj
31
+ 5 0 obj
32
+ <<
33
+ /D [ 4 0 R /FitH 826 ]
34
+ /S /GoTo
35
+ >>
36
+ endobj
37
+ 6 0 obj
38
+ <<
39
+ /Dests 7 0 R
40
+ >>
41
+ endobj
42
+ 7 0 obj
43
+ <<
44
+ /Names [ (JR\137PAGE\137ANCHOR\1370\1371) 5 0 R ]
45
+ >>
46
+ endobj
47
+ xref
48
+ 0 8
49
+ 0000000000 65535 f
50
+ 0000000015 00000 n
51
+ 0000000074 00000 n
52
+ 0000000114 00000 n
53
+ 0000000176 00000 n
54
+ 0000000266 00000 n
55
+ 0000000319 00000 n
56
+ 0000000353 00000 n
57
+ trailer
58
+ <<
59
+ /Size 8
60
+ /Root 3 0 R
61
+ /Info 2 0 R
62
+ >>
63
+ startxref
64
+ 424
65
+ %%EOF
data/test/test_pdf.rb CHANGED
@@ -18,3 +18,4 @@ require_relative 'test_annotations'
18
18
  require_relative 'test_forms'
19
19
  require_relative 'test_xrefs'
20
20
  require_relative 'test_object_tree'
21
+ require_relative 'test_pdf_tree_leaf'
@@ -11,25 +11,25 @@ class TestEncryption < Minitest::Test
11
11
 
12
12
  def test_encrypt_rc4_40b
13
13
  return if OpenSSL::VERSION[0].to_i > 2
14
- @output.string = ""
14
+ @output.string = ::String.new
15
15
  @target.encrypt(cipher: 'rc4', key_size: 40).save(@output)
16
16
  end
17
17
 
18
18
  def test_encrypt_rc4_128b
19
19
  return if OpenSSL::VERSION[0].to_i > 2
20
- @output.string = ""
20
+ @output.string = ::String.new
21
21
  @target.encrypt(cipher: 'rc4', key_size: 128).save(@output)
22
22
  end
23
23
 
24
24
  def test_encrypt_aes_128b
25
25
  return if OpenSSL::VERSION[0].to_i > 2
26
- @output.string = ""
26
+ @output.string = ::String.new
27
27
  @target.encrypt(cipher: 'aes', key_size: 128).save(@output)
28
28
  end
29
29
 
30
30
  def test_decrypt_rc4_40b
31
31
  return if OpenSSL::VERSION[0].to_i > 2
32
- @output.string = ""
32
+ @output.string = ::String.new
33
33
 
34
34
  pdf = PDF.new.encrypt(cipher: 'rc4', key_size: 40)
35
35
  pdf.Catalog[:Test] = "test"
@@ -45,7 +45,7 @@ class TestEncryption < Minitest::Test
45
45
 
46
46
  def test_decrypt_rc4_128b
47
47
  return if OpenSSL::VERSION[0].to_i > 2
48
- @output.string = ""
48
+ @output.string = ::String.new
49
49
  pdf = PDF.new.encrypt(cipher: 'rc4', key_size: 128)
50
50
  pdf.Catalog[:Test] = "test"
51
51
  pdf.save(@output)
@@ -60,7 +60,7 @@ class TestEncryption < Minitest::Test
60
60
 
61
61
  def test_decrypt_aes_128b
62
62
  return if OpenSSL::VERSION[0].to_i > 2
63
- @output.string = ""
63
+ @output.string = ::String.new
64
64
  pdf = PDF.new.encrypt(cipher: 'aes', key_size: 128)
65
65
  pdf.Catalog[:Test] = "test"
66
66
  pdf.save(@output)
@@ -74,7 +74,7 @@ class TestEncryption < Minitest::Test
74
74
  end
75
75
 
76
76
  def test_decrypt_aes_256b
77
- @output.string = ""
77
+ @output.string = ::String.new
78
78
  pdf = PDF.new.encrypt(cipher: 'aes', key_size: 256)
79
79
  pdf.Catalog[:Test] = "test"
80
80
  pdf.save(@output)
@@ -88,7 +88,7 @@ class TestEncryption < Minitest::Test
88
88
  end
89
89
 
90
90
  def test_crypt_filter
91
- @output.string = ""
91
+ @output.string = ::String.new
92
92
  pdf = PDF.new.encrypt(cipher: 'aes', key_size: 256)
93
93
 
94
94
  pdf.Catalog[:S1] = Stream.new("test", :Filter => :Crypt)
@@ -0,0 +1,20 @@
1
+ require 'minitest/autorun'
2
+ require 'stringio'
3
+
4
+ class TestNameTreeLeaf < Minitest::Test
5
+ def setup
6
+ @pdf_path = File.join(__dir__, 'dataset', 'name_tree_leaf.pdf')
7
+ @pdf = Origami::PDF.read(
8
+ @pdf_path,
9
+ ignore_errors: false,
10
+ verbosity: Origami::Parser::VERBOSE_QUIET
11
+ )
12
+ end
13
+
14
+ def test_read_and_save_does_not_raise_type_error
15
+ buf = StringIO.new
16
+ assert_silent do
17
+ @pdf.save(buf)
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origamindee
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Delugré
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-03-26 00:00:00.000000000 Z
12
+ date: 2025-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: base64
@@ -252,6 +252,7 @@ files:
252
252
  - test/dataset/empty.pdf
253
253
  - test/dataset/image_only.pdf
254
254
  - test/dataset/invoice.pdf
255
+ - test/dataset/name_tree_leaf.pdf
255
256
  - test/test_actions.rb
256
257
  - test/test_annotations.rb
257
258
  - test/test_forms.rb
@@ -265,6 +266,7 @@ files:
265
266
  - test/test_pdf_parse.rb
266
267
  - test/test_pdf_parse_lazy.rb
267
268
  - test/test_pdf_sign.rb
269
+ - test/test_pdf_tree_leaf.rb
268
270
  - test/test_streams.rb
269
271
  - test/test_xrefs.rb
270
272
  homepage: https://github.com/mindee/origamindee