mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
126063 aleahu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1) 126025 aleahu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2) 125910 rmunteanu: MNT-15553 : Inconsistent search result with .eml files. - Fix transformation for eml files containing nested alternative parts. - Added test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127840 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
41
config/quick/quick.nested.alternative.eml
Normal file
41
config/quick/quick.nested.alternative.eml
Normal file
@@ -0,0 +1,41 @@
|
||||
MIME-Version: 1.0
|
||||
Received: by 10.000.0.000 with HTTP; Thu, 16 Aug 2012 08:13:29 -0700 (PDT)
|
||||
Date: Thu, 16 Aug 2012 16:13:29 +0100
|
||||
Delivered-To: jane.doe@alfresco.com
|
||||
Message-ID: <CAL0uq1f9vPczLRinL3xB5U_oSSd5U0ob=408nBgosCY0OVFyBw@mail.alfresco.com>
|
||||
Subject: Attachment test
|
||||
From: <john.doe@alfresco.com>
|
||||
To: <jane.doe@alfresco.com>
|
||||
Content-Type: multipart/related;
|
||||
boundary="--_=_NextPart1_03fb5278-acd0-44a8-88cd-bfd1347fd423";
|
||||
type="multipart/alternative"
|
||||
|
||||
This is a multi-part message in MIME format.
|
||||
|
||||
----_=_NextPart1_03fb5278-acd0-44a8-88cd-bfd1347fd423
|
||||
Content-Type: multipart/alternative; boundary="--_=_NextPart0_f68fab3d-a986-41a5-9cf0-3a3aefb21362"
|
||||
|
||||
|
||||
----_=_NextPart0_f68fab3d-a986-41a5-9cf0-3a3aefb21362
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
nested alternative plain text
|
||||
|
||||
----_=_NextPart0_f68fab3d-a986-41a5-9cf0-3a3aefb21362
|
||||
Content-Type: text/html; charset="utf-8"
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
<div dir=3D"ltr">nested alternative html text</div>
|
||||
|
||||
----_=_NextPart0_f68fab3d-a986-41a5-9cf0-3a3aefb21362--
|
||||
|
||||
----_=_NextPart1_03fb5278-acd0-44a8-88cd-bfd1347fd423
|
||||
Content-Type: image/jpeg; name="image001.jpg"
|
||||
Content-Transfer-Encoding: base64
|
||||
Content-ID: <image001.jpg@01D146F0.63006280>
|
||||
|
||||
image
|
||||
|
||||
----_=_NextPart1_03fb5278-acd0-44a8-88cd-bfd1347fd423--
|
||||
|
@@ -169,8 +169,16 @@ public class EMLTransformer extends AbstractContentTransformer2
|
||||
partToUse = part;
|
||||
break;
|
||||
}
|
||||
else if (part.getContentType().contains(MimetypeMap.MIMETYPE_HTML)){
|
||||
else if (part.getContentType().contains(MimetypeMap.MIMETYPE_HTML))
|
||||
{
|
||||
partToUse = part;
|
||||
}
|
||||
else if (part.getContentType().contains(MimetypeMap.MIMETYPE_MULTIPART_ALTERNATIVE))
|
||||
{
|
||||
if (part.getContent() instanceof Multipart)
|
||||
{
|
||||
processAlternativeMultipart((Multipart) part.getContent(), sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (partToUse != null)
|
||||
|
@@ -53,6 +53,8 @@ public class EMLTransformerTest extends AbstractContentTransformerTest
|
||||
|
||||
private static final String QUICK_EML_ALTERNATIVE_CONTENT = "alternative plain text";
|
||||
|
||||
private static final String QUICK_EML_NESTED_ALTERNATIVE_CONTENT = "nested alternative plain text";
|
||||
|
||||
private static final String HTML_SPACE_SPECIAL_CHAR = " ";
|
||||
|
||||
private EMLTransformer transformer;
|
||||
@@ -162,13 +164,33 @@ public class EMLTransformerTest extends AbstractContentTransformerTest
|
||||
assertTrue(contentStr.contains(QUICK_EML_ALTERNATIVE_CONTENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test transforming a valid eml with nested mimetype multipart/alternative to text
|
||||
*/
|
||||
public void testRFC822NestedAlternativeToText() throws Exception
|
||||
{
|
||||
File emlSourceFile = loadQuickTestFile("nested.alternative.eml");
|
||||
File txtTargetFile = TempFileProvider.createTempFile("test5", ".txt");
|
||||
ContentReader reader = new FileContentReader(emlSourceFile);
|
||||
reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
|
||||
ContentWriter writer = new FileContentWriter(txtTargetFile);
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
|
||||
transformer.transform(reader, writer);
|
||||
|
||||
ContentReader reader2 = new FileContentReader(txtTargetFile);
|
||||
reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
String contentStr = reader2.getContentString();
|
||||
assertTrue(contentStr.contains(QUICK_EML_NESTED_ALTERNATIVE_CONTENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test transforming a valid eml with a html part containing html special characters to text
|
||||
*/
|
||||
public void testHtmlSpecialCharsToText() throws Exception
|
||||
{
|
||||
File emlSourceFile = loadQuickTestFile("htmlChars.eml");
|
||||
File txtTargetFile = TempFileProvider.createTempFile("test5", ".txt");
|
||||
File txtTargetFile = TempFileProvider.createTempFile("test6", ".txt");
|
||||
ContentReader reader = new FileContentReader(emlSourceFile);
|
||||
reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
|
||||
ContentWriter writer = new FileContentWriter(txtTargetFile);
|
||||
|
Reference in New Issue
Block a user