origami 1.2.3 → 1.2.4

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.
@@ -4,26 +4,26 @@
4
4
  hexview.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
26
- require 'gui/hexdump'
26
+ require 'gui/gtkhex'
27
27
 
28
28
  module PDFWalker
29
29
 
@@ -44,21 +44,15 @@ module PDFWalker
44
44
  set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
45
45
 
46
46
  @current_obj = nil
47
- @valuebuffer = TextBuffer.new
48
- @valueview = TextView.new(@valuebuffer).set_editable(false).set_cursor_visible(false).set_left_margin(5).set_right_margin(5)
47
+
48
+ @view = HexEditor.new
49
+ @view.show_offsets(true)
49
50
 
50
- @valuebuffer.create_tag( "HexView",
51
- :weight => Pango::WEIGHT_BOLD,
52
- #:foreground => "black",
53
- :family => "Courier",
54
- :scale => Pango::AttrScale::LARGE
55
- )
56
-
57
- add_with_viewport @valueview
51
+ add_with_viewport @view
58
52
  end
59
53
 
60
54
  def clear
61
- @valuebuffer.set_text("")
55
+ @view.set_data ''
62
56
  end
63
57
 
64
58
  def load(object)
@@ -69,14 +63,11 @@ module PDFWalker
69
63
 
70
64
  case object
71
65
  when Origami::Stream
72
- @valuebuffer.set_text(object.data.to_s.hexdump)
73
- when Origami::HexaString
74
- @valuebuffer.set_text(object.value.to_s.hexdump)
75
- when Origami::ByteString
76
- @valuebuffer.set_text(object.to_utf8)
66
+ @view.set_data(object.data)
67
+ when Origami::String
68
+ @view.set_data(object.value)
77
69
  end
78
70
 
79
- @valuebuffer.apply_tag("HexView", @valuebuffer.start_iter, @valuebuffer.end_iter)
80
71
  @current_obj = object
81
72
 
82
73
  rescue Exception => e
@@ -4,22 +4,22 @@
4
4
  imgview.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
@@ -4,22 +4,22 @@
4
4
  menu.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
@@ -266,7 +266,7 @@ module PDFWalker
266
266
 
267
267
  AccelMap.add_entry("<PDF Walker>/File/Open", Gdk::Keyval::GDK_O, Gdk::Window::CONTROL_MASK)
268
268
  AccelMap.add_entry("<PDF Walker>/File/Refresh", Gdk::Keyval::GDK_R, Gdk::Window::CONTROL_MASK)
269
- AccelMap.add_entry("<PDF Walker>/File/Close", Gdk::Keyval::GDK_X, Gdk::Window::CONTROL_MASK)
269
+ AccelMap.add_entry("<PDF Walker>/File/Close", Gdk::Keyval::GDK_W, Gdk::Window::CONTROL_MASK)
270
270
  AccelMap.add_entry("<PDF Walker>/File/Save", Gdk::Keyval::GDK_S, Gdk::Window::CONTROL_MASK)
271
271
  AccelMap.add_entry("<PDF Walker>/File/Quit", Gdk::Keyval::GDK_Q, Gdk::Window::CONTROL_MASK)
272
272
  AccelMap.add_entry("<PDF Walker>/Document/Search", Gdk::Keyval::GDK_F, Gdk::Window::CONTROL_MASK)
@@ -4,22 +4,22 @@
4
4
  properties.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
@@ -54,21 +54,34 @@ module PDFWalker
54
54
  super("Document properties", parent, Dialog::MODAL, [Stock::CLOSE, Dialog::RESPONSE_NONE])
55
55
 
56
56
  docframe = Frame.new(" File properties ")
57
+ stat = File.stat(parent.filename)
57
58
 
58
- i = Iconv.new("UTF-8//IGNORE//TRANSLIT", "ISO-8859-1")
59
+ if RUBY_VERSION < '1.9'
60
+ require 'iconv'
61
+ i = Iconv.new("UTF-8//IGNORE//TRANSLIT", "ISO-8859-1")
62
+
63
+ creation_date = i.iconv(stat.ctime.to_s)
64
+ last_modified = i.iconv(stat.mtime.to_s)
65
+ fd = File.open(parent.filename, 'rb')
66
+ md5sum = Digest::MD5.hexdigest(fd.read)
67
+ fd.close
68
+ i.close
69
+ else
70
+ creation_date = stat.ctime.to_s.encode("utf-8", :invalid => :replace, :undef => :replace)
71
+ last_modified = stat.mtime.to_s.encode("utf-8", :invalid => :replace, :undef => :replace)
72
+ md5sum = Digest::MD5.hexdigest(File.binread(parent.filename))
73
+ end
59
74
 
60
- stat = File.stat(parent.filename)
61
75
  labels =
62
76
  [
63
77
  [ "Filename:", parent.filename ],
64
78
  [ "File size:", "#{File.size(parent.filename)} bytes" ],
65
- [ "MD5:", Digest::MD5.hexdigest(File.open(parent.filename).read) ],
79
+ [ "MD5:", md5sum ],
66
80
  [ "Read-only:", "#{not stat.writable?}" ],
67
- [ "Creation date:", i.iconv("#{stat.ctime}") ],
68
- [ "Last modified:", i.iconv("#{stat.mtime}") ]
81
+ [ "Creation date:", creation_date ],
82
+ [ "Last modified:", last_modified ]
69
83
  ]
70
- i.close
71
-
84
+
72
85
  doctable = Table.new(labels.size + 1, 3)
73
86
 
74
87
  row = 0
@@ -4,22 +4,22 @@
4
4
  signing.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
@@ -4,28 +4,25 @@
4
4
  textview.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
26
- require 'kconv'
27
- require 'gui/hexdump'
28
-
29
26
  module PDFWalker
30
27
 
31
28
  class Walker < Window
@@ -56,7 +53,7 @@ module PDFWalker
56
53
 
57
54
  @pdfbuffer.create_tag("Object",
58
55
  :weight => Pango::WEIGHT_BOLD,
59
- :foreground => "darkblue",
56
+ #:foreground => "darkblue",
60
57
  :family => "Courier",
61
58
  :scale => Pango::AttrScale::LARGE
62
59
  )
@@ -74,15 +71,15 @@ module PDFWalker
74
71
  stm = "#{object.no} #{object.generation} obj\n"
75
72
  stm << object.dictionary.to_s
76
73
 
77
- if object.rawdata.is_binary_data?
78
- stm << "stream\n[Binary data]\nendstream"
79
- else
80
- stm << "stream\n#{object.rawdata}endstream"
81
- end
74
+ #if object.rawdata.is_binary_data?
75
+ # stm << "stream\n[Binary data]\nendstream"
76
+ #else
77
+ # stm << "stream\n#{object.rawdata}endstream"
78
+ #end
82
79
 
83
80
  @pdfbuffer.set_text(stm)
84
81
 
85
- elsif (not object.is_a?(::Array) or object.is_a?(Array)) and
82
+ elsif not (object.is_a?(::Array) or object.is_a?(Array)) and
86
83
  not object.is_a?(PDF) and not object.is_a?(Adobe::PPKLite) and
87
84
  not object.is_a?(PDF::Revision) and not object.is_a?(Adobe::PPKLite::Revision) and
88
85
  not object.is_a?(XRefToCompressedObj)
@@ -4,22 +4,22 @@
4
4
  treeview.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
@@ -285,7 +285,7 @@ module PDFWalker
285
285
  name =
286
286
  case object
287
287
  when Origami::String
288
- '"' + object.value + '"'
288
+ '"' + object.to_utf8 + '"'
289
289
  when Origami::Number, Name
290
290
  object.value.to_s
291
291
  else
@@ -6,22 +6,22 @@
6
6
  walker.rb
7
7
 
8
8
  = Info
9
- This file is part of Origami, PDF manipulation framework for Ruby
9
+ This file is part of PDF Walker, a graphical PDF file browser
10
10
  Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
11
11
  All right reserved.
12
12
 
13
- Origami is free software: you can redistribute it and/or modify
14
- it under the terms of the GNU Lesser General Public License as published by
13
+ PDF Walker is free software: you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
15
  the Free Software Foundation, either version 3 of the License, or
16
16
  (at your option) any later version.
17
17
 
18
- Origami is distributed in the hope that it will be useful,
18
+ PDF Walker is distributed in the hope that it will be useful,
19
19
  but WITHOUT ANY WARRANTY; without even the implied warranty of
20
20
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- GNU Lesser General Public License for more details.
21
+ GNU General Public License for more details.
22
22
 
23
- You should have received a copy of the GNU Lesser General Public License
24
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
23
+ You should have received a copy of the GNU General Public License
24
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
25
25
 
26
26
  =end
27
27
 
@@ -4,22 +4,22 @@
4
4
  xrefs.rb
5
5
 
6
6
  = Info
7
- This file is part of Origami, PDF manipulation framework for Ruby
7
+ This file is part of PDF Walker, a graphical PDF file browser
8
8
  Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
9
9
  All right reserved.
10
10
 
11
- Origami is free software: you can redistribute it and/or modify
12
- it under the terms of the GNU Lesser General Public License as published by
11
+ PDF Walker is free software: you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
13
  the Free Software Foundation, either version 3 of the License, or
14
14
  (at your option) any later version.
15
15
 
16
- Origami is distributed in the hope that it will be useful,
16
+ PDF Walker is distributed in the hope that it will be useful,
17
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- GNU Lesser General Public License for more details.
19
+ GNU General Public License for more details.
20
20
 
21
- You should have received a copy of the GNU Lesser General Public License
22
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
21
+ You should have received a copy of the GNU General Public License
22
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  =end
25
25
 
@@ -26,11 +26,11 @@
26
26
  =end
27
27
 
28
28
  require 'optparse'
29
- require 'ftools'
29
+ require 'fileutils'
30
30
  begin
31
+ ORIGAMIDIR = "#{File.dirname(__FILE__)}/../lib"
31
32
  require 'origami'
32
33
  rescue LoadError
33
- ORIGAMIDIR = "#{File.dirname(__FILE__)}/../lib"
34
34
  $: << ORIGAMIDIR
35
35
  require 'origami'
36
36
  end
@@ -315,7 +315,11 @@ puts "Processing the object hierarchy..."
315
315
  @current_idx = 0
316
316
  while @current_idx != @obj_route.size
317
317
  varname = @obj_route[@current_idx]
318
- obj = target[@var_hash.index(varname)]
318
+ if RUBY_VERSION < '1.9'
319
+ obj = target[@var_hash.index(varname)]
320
+ else
321
+ obj = target[@var_hash.key(varname)]
322
+ end
319
323
 
320
324
  @code_hash[varname] ||= {}
321
325
  @code_hash[varname][:body] = objectToRuby(obj, 0, varname, true)
@@ -102,8 +102,8 @@ begin
102
102
 
103
103
  pdf = PDF.read(target, params)
104
104
  pdf.encrypt(
105
- :user_password => @options[:password],
106
- :owner_password => @options[:password],
105
+ :user_passwd => @options[:password],
106
+ :owner_passwd => @options[:password],
107
107
  :cipher => @options[:cipher],
108
108
  :key_size => @options[:key_size],
109
109
  :hardened => @options[:hardened]