Skip to content

Commit

Permalink
Don't set the Content-Type name parameters when extracting tnef messa…
Browse files Browse the repository at this point in the history
…ge bodies

Fixes issue #435
  • Loading branch information
jstedfast committed Sep 27, 2018
1 parent 4918354 commit 33f00db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 0 additions & 3 deletions MimeKit/Tnef/TnefPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ static void ExtractMapiProperties (TnefReader reader, MimeMessage message, BodyB
prop.PropertyTag.ValueTnefType == TnefPropertyType.Unicode ||
prop.PropertyTag.ValueTnefType == TnefPropertyType.Binary) {
var rtf = new TextPart ("rtf");
rtf.ContentType.Name = "body.rtf";

var converter = new RtfCompressedToRtf ();
var content = new MemoryBlockStream ();
Expand All @@ -167,7 +166,6 @@ static void ExtractMapiProperties (TnefReader reader, MimeMessage message, BodyB
prop.PropertyTag.ValueTnefType == TnefPropertyType.Unicode ||
prop.PropertyTag.ValueTnefType == TnefPropertyType.Binary) {
var html = new TextPart ("html");
html.ContentType.Name = "body.html";
Encoding encoding;

if (prop.PropertyTag.ValueTnefType != TnefPropertyType.Unicode)
Expand All @@ -185,7 +183,6 @@ static void ExtractMapiProperties (TnefReader reader, MimeMessage message, BodyB
prop.PropertyTag.ValueTnefType == TnefPropertyType.Unicode ||
prop.PropertyTag.ValueTnefType == TnefPropertyType.Binary) {
var plain = new TextPart ("plain");
plain.ContentType.Name = "body.txt";
Encoding encoding;

if (prop.PropertyTag.ValueTnefType != TnefPropertyType.Unicode)
Expand Down
17 changes: 16 additions & 1 deletion UnitTests/Tnef/TnefTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,22 @@ static void TestTnefParser (string path, TnefComplianceStatus expected = TnefCom
bool found = false;

foreach (var part in attachments.OfType<MimePart> ()) {
if (part.FileName == name) {
if (part is TextPart && string.IsNullOrEmpty (part.FileName)) {
var basename = Path.GetFileNameWithoutExtension (name);
var extension = Path.GetExtension (name);
string subtype;

switch (extension) {
case ".html": subtype = "html"; break;
case ".rtf": subtype = "rtf"; break;
default: subtype = "plain"; break;
}

if (basename == "body" && part.ContentType.IsMimeType ("text", subtype)) {
found = true;
break;
}
} else if (part.FileName == name) {
found = true;
break;
}
Expand Down

0 comments on commit 33f00db

Please sign in to comment.