diff --git a/lib/mapi/convert/note-mime.rb b/lib/mapi/convert/note-mime.rb index 494cf11..7b81bc6 100644 --- a/lib/mapi/convert/note-mime.rb +++ b/lib/mapi/convert/note-mime.rb @@ -81,9 +81,9 @@ def populate_headers recips_by_type = recipients.group_by { |r| r.type } # i want to the the types in a specific order. [:to, :cc, :bcc].each do |type| - # don't know why i bother, but if we can, we try to sort recipients by the numerical part - # of the ole name, or just leave it if we can't - recips = recips_by_type[type] + # for maximal (probably pointless) fidelity, we try to sort recipients by the + # numerical part of the ole name + recips = recips_by_type[type] || [] recips = (recips.sort_by { |r| r.obj.name[/\d{8}$/].hex } rescue recips) # switched to using , for separation, not ;. see issue #4 # recips.empty? is strange. i wouldn't have thought it possible, but it was right? diff --git a/lib/mapi/msg.rb b/lib/mapi/msg.rb index c7cfb55..6414db7 100644 --- a/lib/mapi/msg.rb +++ b/lib/mapi/msg.rb @@ -193,8 +193,8 @@ def self.parse_nameid obj pseudo_prop = 0x8000 + offset named = flags & 1 == 1 prop = if named - str_off = *str.unpack('V') - len = *names_data[str_off, 4].unpack('V') + str_off = str.unpack('V').first + len = names_data[str_off, 4].unpack('V').first Ole::Types::FROM_UTF16.iconv names_data[str_off + 4, len] else a, b = str.unpack('v2') diff --git a/lib/mapi/property_set.rb b/lib/mapi/property_set.rb index 5b4be82..4c7d028 100644 --- a/lib/mapi/property_set.rb +++ b/lib/mapi/property_set.rb @@ -249,7 +249,7 @@ def body # for providing rtf decompression def body_rtf return @body_rtf if defined?(@body_rtf) - @body_rtf = (RTF.rtfdecompr rtf_compressed.read rescue nil) + @body_rtf = (RTF.rtfdecompr rtf_compressed.read)# rescue nil) end # for providing rtf to html conversion diff --git a/lib/mapi/rtf.rb b/lib/mapi/rtf.rb index 9fa133f..b61f6ce 100644 --- a/lib/mapi/rtf.rb +++ b/lib/mapi/rtf.rb @@ -2,6 +2,14 @@ require 'strscan' require 'rtf' +class StringIO # :nodoc: + begin + instance_method :getbyte + rescue NameError + alias getbyte getc + end +end + module Mapi # # = Introduction @@ -46,9 +54,9 @@ def rtfdecompr data flags = nil while rtf.length < uncompr_size and !io.eof? # each flag byte flags 8 literals/references, 1 per bit - flags = ((flag_count += 1) % 8 == 0) ? io.getc : flags >> 1 + flags = ((flag_count += 1) % 8 == 0) ? io.getbyte : flags >> 1 if 1 == (flags & 1) # each flag bit is 1 for reference, 0 for literal - rp, l = io.getc, io.getc + rp, l = io.getbyte, io.getbyte # offset is a 12 byte number. 2^12 is 4096, so thats fine rp = (rp << 4) | (l >> 4) # the offset relative to block start l = (l & 0xf) + 2 # the number of bytes to copy @@ -58,7 +66,7 @@ def rtfdecompr data rp = (rp + 1) % 4096 end else - rtf << buf[wp] = io.getc + rtf << buf[wp] = io.getbyte.chr wp = (wp + 1) % 4096 end end