Skip to content

Commit 67abdfb

Browse files
committed
Treat 0x001f as 0x001e
Looking at the MS reference [1], 001E or 001F should be PT_STRING8. Mapi::Types::DATA seems to ignore this. It sets 001f as PT_UNICODE, and this sort of maps to the original filter converting to UTF8. I say sort of, because I'm not sure how how Mapi::Types::DATA and Mapi::Msg::PropertySTore::ENCODINGS interact. This change at least makes both the existing and new spec pass ¯\_(ツ)_/¯ [1] https://msdn.microsoft.com/en-us/library/bb147591.aspx
1 parent fac10c8 commit 67abdfb

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/mapi/msg.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class PropertyStore
101101
# change these to use mapi symbolic const names
102102
ENCODINGS = {
103103
0x000d => proc { |obj| obj }, # seems to be used when its going to be a directory instead of a file. eg nested ole. 3701 usually. in which case we shouldn't get here right?
104-
0x001f => proc { |obj| Ole::Types::FROM_UTF16.iconv obj.read }, # unicode
104+
0x001f => proc { |obj| obj.read.chomp 0.chr },
105105
# ascii
106106
# FIXME hack did a[0..-2] before, seems right sometimes, but for some others it chopped the text. chomp
107107
0x001e => proc { |obj| obj.read.chomp 0.chr },
30 KB
Binary file not shown.

test/test_msg.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ def test_rendered_string_is_valid_encoding
3535
end
3636
end
3737

38+
def test_multipart_rendered_string_is_valid_encoding
39+
msg = Mapi::Msg.open "#{TEST_DIR}/small-business-rates-relief.msg" do |msg|
40+
string_version = msg.to_mime.to_s
41+
if string_version.respond_to?(:valid_encoding?)
42+
assert_equal true, string_version.valid_encoding?
43+
end
44+
end
45+
end
46+
3847
def test_embedded_msg_renders_as_string
3948
msg = Mapi::Msg.open "#{TEST_DIR}/embedded.msg" do |msg|
4049
assert_match "message/rfc822", msg.to_mime.to_s

0 commit comments

Comments
 (0)