From 3fc3975e83fa9f304f6476598755df4b36f75b26 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Fri, 23 Oct 2015 18:41:58 +0100 Subject: [PATCH] Remove previous fix - see comments at https://github.com/aquasync/ruby-msg/pull/5#issuecomment-50475467 --- lib/mapi/property_set.rb | 5 ---- test/test_msg.rb | 59 +++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/lib/mapi/property_set.rb b/lib/mapi/property_set.rb index 1e6bf79..d911b98 100644 --- a/lib/mapi/property_set.rb +++ b/lib/mapi/property_set.rb @@ -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 diff --git a/test/test_msg.rb b/test/test_msg.rb index 80e5beb..0092898 100644 --- a/test/test_msg.rb +++ b/test/test_msg.rb @@ -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" ', 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" ', 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