origami 1.2.6 → 1.2.7

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
  SHA1:
3
- metadata.gz: 400584bfa83ed0b47e3501f85f6ea19733aa365a
4
- data.tar.gz: ebe216889afe825f5ea850ac3a330b7b462afb0a
3
+ metadata.gz: d17b0e4071c2342bd02ad39ac239edc3e185296c
4
+ data.tar.gz: ed34fe83604f52063e0340b06e95bce6a2f2c801
5
5
  SHA512:
6
- metadata.gz: a5383fd775e5eb11a8a2a1212b4e8523f9751974fae787fd72074206e435b29b6e5d915c05154e25c12617733b317f20e5a3cd3c7f099a275ec995ce55308bb8
7
- data.tar.gz: 5dd566b2f6cedca2b1be9b124d809efb46cc8057fc4f6ffbd5a7f22a56c165da1ff0fd1e1ea0e8be8695d98ef8363adbefafeb77fcab256ddea3dad38cbe674a
6
+ metadata.gz: 5332359f279fb3e88d28229f1bbd9b361aaeb84724ce3682d296d67b9d1c729c2c8da288a644add7109f7090692dcc669706e907731a308c13f635931c43dea3
7
+ data.tar.gz: 1fe6ceb2f9cfff14bd15018bc1c965c43ad01e96d46de67538d58c48d9d8a9c97a7dc9b520aeb9b1e2caa2d9958f3f741406a90d4f7f4ee90e9b01d0f9198e89
@@ -82,6 +82,8 @@ if ARGV.empty?
82
82
  else
83
83
  TARGET = ARGV.shift
84
84
  end
85
+
86
+ Origami::OPTIONS[:enable_type_guessing] = Origami::OPTIONS[:enable_type_propagation] = true
85
87
 
86
88
  TARGET_DIR = File.basename(TARGET, '.pdf')
87
89
  TARGET_FILE = "#{TARGET_DIR}/#{TARGET_DIR}.rb"
@@ -99,11 +101,12 @@ def objectToRuby(obj, inclevel = 0, internalname = nil, do_convert = false)
99
101
  when Origami::String
100
102
  "'#{obj.value.gsub("'","\\\\'")}'"
101
103
  when Origami::Dictionary
102
- customtype = nil
103
- if obj[:Type] and Origami::DICT_SPECIAL_TYPES.include?(obj[:Type].value)
104
- customtype = Origami::DICT_SPECIAL_TYPES[obj[:Type].value]
104
+ customclass = nil
105
+ if obj.class != Origami::Dictionary
106
+ p = (obj.class == Origami::Encoding) ? 0 : 1
107
+ customclass = obj.class.to_s.split('::')[p..-1].join('::') # strip Origami prefix if there is no collision
105
108
  end
106
- dictionaryToRuby(obj, inclevel, internalname, customtype)
109
+ dictionaryToRuby(obj, inclevel, internalname, customclass)
107
110
  when Origami::Array
108
111
  arrayToRuby(obj, inclevel, internalname)
109
112
  when Origami::Stream
@@ -1067,7 +1067,7 @@ module Origami
1067
1067
  module Standard
1068
1068
 
1069
1069
  PADDING = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A" #:nodoc:
1070
- PADDING.force_encoding('binary') if RUBY_VERSION > '1.8'
1070
+ PADDING.force_encoding('binary') if RUBY_VERSION >= '1.9'
1071
1071
 
1072
1072
  #
1073
1073
  # Permission constants for encrypted documents.
@@ -1115,7 +1115,7 @@ module Origami
1115
1115
 
1116
1116
  if self.R < 5
1117
1117
  padded = pad_password(userpassword)
1118
- padded.force_encoding('binary') if RUBY_VERSION > '1.8'
1118
+ padded.force_encoding('binary') if RUBY_VERSION >= '1.9'
1119
1119
 
1120
1120
  padded << self.O
1121
1121
  padded << [ self.P ].pack("i")
@@ -199,7 +199,7 @@ module Origami
199
199
  rsrc = ls_resources(type)
200
200
  n = '1'
201
201
 
202
- while rsrc.include? (prefix + n).to_sym
202
+ while rsrc.include?((prefix + n).to_sym)
203
203
  n.next!
204
204
  end
205
205
 
@@ -564,15 +564,15 @@ module Origami
564
564
  raise TypeError, "Invalid parameter type : #{no.class}"
565
565
  end
566
566
 
567
- set = indirect_objects_table
568
-
569
567
  #
570
568
  # Search through accessible indirect objects.
571
569
  #
572
- if set.include?(target)
573
- set[target]
574
- elsif use_xrefstm == true
575
- # Look into XRef streams.
570
+ @revisions.each do |rev|
571
+ return rev.body[target] if rev.body.include?(target)
572
+ end
573
+
574
+ # Look into XRef streams.
575
+ if use_xrefstm == true
576
576
 
577
577
  if @revisions.last.has_xrefstm?
578
578
  xrefstm = @revisions.last.xrefstm
@@ -605,8 +605,12 @@ module Origami
605
605
  #
606
606
  # Lastly search directly into Object streams (might be very slow).
607
607
  #
608
- stream = set.values.find_all{|obj| obj.is_a?(ObjectStream)}.find do |objstm| objstm.include?(target.refno) end
609
- stream && stream.extract(target.refno)
608
+ @revisions.each do |rev|
609
+ streams = rev.objects.find_all{|obj| obj.is_a?(ObjectStream) and obj.include?(target.refno)}
610
+ return streams.first.extract(target.refno) unless streams.empty?
611
+ end
612
+
613
+ nil
610
614
  end
611
615
 
612
616
  end
@@ -1016,10 +1020,6 @@ module Origami
1016
1020
  max
1017
1021
  end
1018
1022
 
1019
- def indirect_objects_table #:nodoc:
1020
- @revisions.inject({}) do |set, rev| set.merge(rev.body) end
1021
- end
1022
-
1023
1023
  def indirect_objects_by_rev #:nodoc:
1024
1024
  @revisions.inject([]) do |set,rev|
1025
1025
  objset = rev.objects
@@ -476,6 +476,7 @@ module Origami
476
476
  objoff += objdata.size
477
477
  data << objdata
478
478
  obj.set_indirect(true)
479
+ obj.no = num
479
480
  end
480
481
 
481
482
  self.data = prolog + data
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origami
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Delugre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-14 00:00:00.000000000 Z
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "Origami is a PDF-compliant parser. This is not a PDF rendering library,
14
14
  it aims at providing a scripting tool to generate and analyze malicious PDF files.
@@ -32,8 +32,8 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - README
36
35
  - COPYING.LESSER
36
+ - README
37
37
  - bin/config/pdfcop.conf.yml
38
38
  - bin/gui/COPYING
39
39
  - bin/gui/about.rb
@@ -62,6 +62,7 @@ files:
62
62
  - bin/pdfmetadata
63
63
  - bin/pdfsh
64
64
  - bin/pdfwalker
65
+ - bin/shell/.irbrc
65
66
  - bin/shell/console.rb
66
67
  - bin/shell/hexdump.rb
67
68
  - lib/origami.rb
@@ -154,7 +155,6 @@ files:
154
155
  - templates/patterns.rb
155
156
  - templates/widgets.rb
156
157
  - templates/xdp.rb
157
- - bin/shell/.irbrc
158
158
  - test/ts_pdf.rb
159
159
  homepage: http://code.google.com/p/origami-pdf
160
160
  licenses:
@@ -166,18 +166,18 @@ require_paths:
166
166
  - lib
167
167
  required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - '>='
169
+ - - ">="
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - '>='
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements:
178
178
  - ruby-gtk2 if you plan to run the PDF Walker interface
179
179
  rubyforge_project:
180
- rubygems_version: 2.0.0
180
+ rubygems_version: 2.2.2
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Origami aims at providing a scripting tool to generate and analyze malicious