Skip to content

Commit ebe1129

Browse files
committed
- Update pack strings for endian fixes.
- Add ChangeLog. git-svn-id: https://ruby-msg.googlecode.com/svn/trunk@114 c30d66de-b626-0410-988f-81f6512a6d81
1 parent f55b37d commit ebe1129

File tree

4 files changed

+97
-14
lines changed

4 files changed

+97
-14
lines changed

ChangeLog

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
== 1.3.2 / ...
2+
3+
- Initial simple msg test case.
4+
- Update TODO, stripping out all the redundant ole stuff.
5+
- Fix property set guids to use the new Ole::Types::Clsid type.
6+
- Add block form Msg.open
7+
- Fix file requires for running tests individually.
8+
- Update RangesIO subclasses for changes in ruby-ole.
9+
- Start to flesh out move to mapi to clean up the way pst hijacks the msg
10+
classes currently.
11+
- Pretty big refactoring, adding initial outlook 2003 pst support.
12+
- Merge initial pst reading code (converted from libpst).
13+
- Add a ChangeLog :).
14+
15+
== 1.3.1 / 2007-08-21
16+
17+
- Add fix for issue #2, and #4.
18+
- Move ole code to ruby-ole project, and depend on it.
19+
20+
== 1.2.17 / 2007-05-13
21+
22+
(this was last release before splitting out ruby-ole. subsequent bug fix
23+
point releases 1-3 were made directly on the gem, not reflected in the
24+
repository, though the fixes were also forward-ported.)
25+
26+
- Update Ole::Storage backend, finalising api for split to separate
27+
library.
28+
29+
== 1.2.16 / 2007-04-28
30+
31+
- Some minor fixes to msg parser.
32+
- Extending RTF and body conversion support.
33+
- Initial look at possible wmf conversion for embedded images.
34+
- Add initial cli converter tool
35+
- Add rdoc to ole/storage, and msg/properties
36+
- Add streaming IO support to Ole::Storage, and use it in Msg::Properties
37+
- Updates to test cases
38+
- Add README, and update TODO
39+
- Convert rtf support tools in c to small ruby class.
40+
- Merge preliminary write support for Ole::Storage, as well as preliminary
41+
filesystem api.
42+
43+
== 1.2.13 / 2007-01-22
44+
45+
- Nested msg support
46+
47+
== 1.2.10 / 2007-01-21
48+
49+
- Add initial vcard support.
50+
- Implement a named properties map, for vcard conversion.
51+
- Add orderedhash to Mime for keeping header order
52+
- Fix line endings in lib/mime
53+
- First released version
54+
55+
== <= 1.2.9 / 2007-01-11..2007-01-19
56+
57+
(haven't bothered to note exact versions and dates - nothing here was released.
58+
can look at history of lib/msg.rb to see exact VERSION at each commit.)
59+
60+
- Merged most of the named property work.
61+
- Added some test files.
62+
- Update svn:ignore, to exclude test messages and ole files which I can't
63+
release. Need to get some clean files for use in test cases.
64+
Also excluding source to the mapitags files for the moment.
65+
A lot of it is not redistributable
66+
- Added a converter to extract embedded html in rtf. Downloaded somewhere,
67+
source unknown.
68+
- Minor fix to ole/storage.rb, after new OleDir#type behaviour
69+
- Imported support.rb, replacing previously required std.rb
70+
- Added initial support for parsing times in Msg::Properties.
71+
- Imported some rtf decompression code and minor updates.
72+
- Cleaned up the ole class a bit
73+
- Fixed OleDir#data method using sb_blocks map (see POLE).
74+

lib/msg/properties.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,16 @@ def self.parse_nameid obj
239239
# not sure about any of this stuff really.
240240
# should flip a few bits in the real msg, to get a better understanding of how this works.
241241
props = props_obj.read.scan(/.{8}/m).map do |str|
242-
flags, offset = str[4..-1].unpack 'S2'
242+
flags, offset = str[4..-1].unpack 'v2'
243243
# the property will be serialised as this pseudo property, mapping it to this named property
244244
pseudo_prop = 0x8000 + offset
245245
named = flags & 1 == 1
246246
prop = if named
247-
str_off = *str.unpack('L')
248-
len = *names_data[str_off, 4].unpack('L')
247+
str_off = *str.unpack('V')
248+
len = *names_data[str_off, 4].unpack('V')
249249
Ole::Types::FROM_UTF16.iconv names_data[str_off + 4, len]
250250
else
251-
a, b = str.unpack('S2')
251+
a, b = str.unpack('v2')
252252
Log.debug "b not 0" if b != 0
253253
a
254254
end
@@ -275,7 +275,7 @@ def parse_substg key, encoding, offset, obj
275275
# equal to the lengths of all the sub parts. gives an implied array size i suppose.
276276
# maybe you can initialize the array at this time. the sizes are the same as all the
277277
# ole object sizes anyway, its to pre-allocate i suppose.
278-
#p obj.data.unpack('L*')
278+
#p obj.data.unpack('V*')
279279
# ignore this one
280280
return
281281
else
@@ -305,7 +305,7 @@ def parse_properties obj
305305
Log.warn "padding was not as expected #{pad} (#{data.length}) -> #{data[0...pad].inspect}"
306306
end
307307
data[pad..-1].scan(/.{16}/m).each do |data|
308-
property, encoding = ('%08x' % data.unpack('L')).scan /.{4}/
308+
property, encoding = ('%08x' % data.unpack('V')).scan /.{4}/
309309
key = property.hex
310310
# doesn't make any sense to me. probably because its a serialization of some internal
311311
# outlook structure...
@@ -316,12 +316,12 @@ def parse_properties obj
316316
# multivalue versions ignored also
317317
when '0003' # long
318318
# don't know what all the other data is for
319-
add_property key, *data[8, 4].unpack('L')
319+
add_property key, *data[8, 4].unpack('V')
320320
when '000b' # boolean
321321
# again, heaps more data than needed. and its not always 0 or 1.
322322
# they are in fact quite big numbers. this is wrong.
323323
# p [property, data[4..-1].unpack('H*')[0]]
324-
add_property key, data[8, 4].unpack('L')[0] != 0
324+
add_property key, data[8, 4].unpack('V')[0] != 0
325325
when '0040' # systime
326326
# seems to work:
327327
add_property key, Ole::Types.load_time(data[8..-1])
@@ -459,7 +459,10 @@ def body_html
459459
@body_html = (self[:body_html].read rescue nil)
460460
@body_html = (Msg::RTF.rtf2html body_rtf rescue nil) if !@body_html or @body_html.strip.empty?
461461
# last resort
462-
@body_html = (::RTF::Converter.rtf2text body_rtf, :html rescue nil) if !@body_html or @body_html.strip.empty?
462+
if !@body_html or @body_html.strip.empty?
463+
Log.warn 'creating html body from rtf'
464+
@body_html = (::RTF::Converter.rtf2text body_rtf, :html rescue nil)
465+
end
463466
@body_html
464467
end
465468

lib/msg/rtf.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'stringio'
22
require 'strscan'
33

4-
require 'rtf.rb'
4+
require 'rtf'
55

66
class Msg
77
#
@@ -35,7 +35,7 @@ def rtfdecompr data
3535
rtf = ''
3636

3737
# get header fields (as defined in RTFLIB.H)
38-
compr_size, uncompr_size, magic, crc32 = io.read(16).unpack 'L*'
38+
compr_size, uncompr_size, magic, crc32 = io.read(16).unpack 'V*'
3939
#warn "compressed-RTF data size mismatch" unless io.size == data.compr_size + 4
4040

4141
# process the data
@@ -46,7 +46,6 @@ def rtfdecompr data
4646
flag_count = -1
4747
flags = nil
4848
while rtf.length < uncompr_size and !io.eof?
49-
#p [rtf.length, uncompr_size]
5049
# each flag byte flags 8 literals/references, 1 per bit
5150
flags = ((flag_count += 1) % 8 == 0) ? io.getc : flags >> 1
5251
if 1 == (flags & 1) # each flag bit is 1 for reference, 0 for literal
@@ -55,18 +54,24 @@ def rtfdecompr data
5554
rp = (rp << 4) | (l >> 4) # the offset relative to block start
5655
l = (l & 0xf) + 2 # the number of bytes to copy
5756
l.times do
58-
rtf << (buf[wp] = buf[rp])
57+
rtf << buf[wp] = buf[rp]
5958
wp = (wp + 1) % 4096
6059
rp = (rp + 1) % 4096
6160
end
6261
else
63-
rtf << (buf[wp] = io.getc)
62+
rtf << buf[wp] = io.getc
6463
wp = (wp + 1) % 4096
6564
end
6665
end
6766
else # unknown magic number
6867
raise "Unknown compression type (magic number 0x%08x)" % magic
6968
end
69+
70+
# not sure if its due to a bug in the above code. doesn't seem to be
71+
# in my tests, but sometimes there's a trailing null. we chomp it here,
72+
# which actually makes the resultant rtf smaller than its advertised
73+
# size (+uncompr_size+).
74+
rtf.chomp! 0.chr
7075
rtf
7176
end
7277

lib/pst.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ def initialize pst, list
829829
# NOTE we take the last value seen value if there are duplicates. this "fixes"
830830
# test4-o1997.pst for the time being.
831831
warn "there are duplicate id2 records with id #{id2.id2}" if @id_from_id2[id2.id2]
832+
next if @id_from_id2[id2.id2]
832833
@id_from_id2[id2.id2] = id2.id
833834
end
834835
end

0 commit comments

Comments
 (0)