Skip to content

Commit

Permalink
Remove previous fix - see comments at aquasync#5 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowbot committed Nov 3, 2015
1 parent 5a86dfa commit 3fc3975
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
5 changes: 0 additions & 5 deletions lib/mapi/property_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ def body_html
end
end
end
if @body_html && @body_html.respond_to?(:encoding)
@body_html.force_encoding("utf-8")
@body_html = @body_html.valid_encoding? ? @body_html : @body_html.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8")
end
@body_html
end
end
end
Expand Down
59 changes: 28 additions & 31 deletions test/test_msg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,36 @@
require 'mapi/convert'

class TestMsg < Test::Unit::TestCase
def test_blammo
Mapi::Msg.open "#{TEST_DIR}/test_Blammo.msg" do |msg|
assert_equal '"TripleNickel" <TripleNickel@mapi32.net>', msg.from
assert_equal 'BlammoBlammo', msg.subject
assert_equal 0, msg.recipients.length
assert_equal 0, msg.attachments.length
# this is all properties
assert_equal 66, msg.properties.raw.length
# this is unique named properties
assert_equal 48, msg.properties.to_h.length
# test accessing the named property keys - same name but different namespace
assert_equal 'Yippee555', msg.props['Name4', Ole::Types::Clsid.parse('55555555-5555-5555-c000-000000000046')]
assert_equal 'Yippee666', msg.props['Name4', Ole::Types::Clsid.parse('66666666-6666-6666-c000-000000000046')]
end
end
def test_blammo
Mapi::Msg.open "#{TEST_DIR}/test_Blammo.msg" do |msg|
assert_equal '"TripleNickel" <TripleNickel@mapi32.net>', msg.from
assert_equal 'BlammoBlammo', msg.subject
assert_equal 0, msg.recipients.length
assert_equal 0, msg.attachments.length
# this is all properties
assert_equal 66, msg.properties.raw.length
# this is unique named properties
assert_equal 48, msg.properties.to_h.length
# test accessing the named property keys - same name but different namespace
assert_equal 'Yippee555', msg.props['Name4', Ole::Types::Clsid.parse('55555555-5555-5555-c000-000000000046')]
assert_equal 'Yippee666', msg.props['Name4', Ole::Types::Clsid.parse('66666666-6666-6666-c000-000000000046')]
end
end


def test_rtf_to_html_returns_valid_utf8
msg = Mapi::Msg.open "#{TEST_DIR}/multipart-with-html.msg" do |msg|
assert_equal 1, msg.recipients.length
assert_equal 3, msg.attachments.length
html_part = msg.to_mime.parts[0].parts[1].to_s
if html_part.respond_to?(:encoding)
assert_equal 'UTF-8', html_part.encoding.to_s
assert html_part.valid_encoding?
end
end
end
def test_rendered_string_is_valid_encoding
msg = Mapi::Msg.open "#{TEST_DIR}/multipart-with-html.msg" do |msg|
string_version = msg.to_mime.to_s
if string_version.respond_to?(:valid_encoding?)
assert_equal true, msg.to_mime.to_s.valid_encoding?
end
end
end

def test_embedded_msg_renders_as_string
msg = Mapi::Msg.open "#{TEST_DIR}/embedded.msg" do |msg|
assert_match "message/rfc822", msg.to_mime.to_s
end
end
def test_embedded_msg_renders_as_string
msg = Mapi::Msg.open "#{TEST_DIR}/embedded.msg" do |msg|
assert_match "message/rfc822", msg.to_mime.to_s
end
end
end

0 comments on commit 3fc3975

Please sign in to comment.