Skip to content

Commit

Permalink
UTF-8 umlauts are replaced by question marks (#257)
Browse files Browse the repository at this point in the history
Enabled/fixed test.
  • Loading branch information
marcelmay committed Apr 3, 2020
1 parent 7817883 commit 7186491
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class EncodingTest {
* Message (multipart/alternative)
* \--> Message (text/plain)
*/
@Ignore("https://github.com/greenmail-mail-test/greenmail/issues/257")
@Test
public void testTextPlainWithUTF8() throws MessagingException, IOException {
greenMail.setUser("foo@localhost", "pwd");
Expand All @@ -49,7 +48,7 @@ public void testTextPlainWithUTF8() throws MessagingException, IOException {
multipart.addBodyPart(textQP);

MimeBodyPart html = new MimeBodyPart();
html.setContent("<!doctype html>" +
html.setContent(MimeUtility.encodeText("<!doctype html>" +
"<html lang=en>" +
"<head>" +
"<meta charset=utf-8>" +
Expand All @@ -58,15 +57,20 @@ public void testTextPlainWithUTF8() throws MessagingException, IOException {
"<body>" +
"<p>8BIT Content with umlaut ü</p>" +
"</body>" +
"</html>", "text/html; charset=utf-8");
"</html>", "UTF-8","B"), "text/html; charset=utf-8");
html.setHeader("Content-Transfer-Encoding", "8BIT");
multipart.addBodyPart(html);

MimeBodyPart text = new MimeBodyPart();
text.setText("8BIT Content with umlaut \u00FC", "utf-8");
text.setText(MimeUtility.encodeText("8BIT Content with umlaut \u00FC","UTF-8","B"), "utf-8");
text.setHeader("Content-Transfer-Encoding", "8BIT");
multipart.addBodyPart(text);

MimeBodyPart text2QP = new MimeBodyPart();
text2QP.setText(MimeUtility.encodeText("8BIT Content with umlaut \u00FC","UTF-8","Q"), "utf-8");
text2QP.setHeader("Content-Transfer-Encoding", "8BIT");
multipart.addBodyPart(text2QP);


// New main message, containing body part
MimeMessage message = new MimeMessage(session);
Expand Down Expand Up @@ -105,6 +109,9 @@ public void testTextPlainWithUTF8() throws MessagingException, IOException {
assertEquals("TEXT/PLAIN; charset=utf-8", bodyPart2.getContentType());
assertEquals(text.getContent(), bodyPart2.getContent());

final BodyPart bodyPart3 = multipartReceived.getBodyPart(3);
assertEquals("TEXT/PLAIN; charset=utf-8", bodyPart3.getContentType());
assertEquals(text2QP.getContent(), bodyPart3.getContent());
} finally {
store.close();
}
Expand Down

0 comments on commit 7186491

Please sign in to comment.