From f98dcd4fd761bfd4b43b7f1f5b7f7ba98fb18f7f Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 28 Apr 2021 09:11:25 +0200 Subject: [PATCH] Assume UTF8 for HTML --- app/src/main/java/com/sun/mail/handlers/text_plain.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/sun/mail/handlers/text_plain.java b/app/src/main/java/com/sun/mail/handlers/text_plain.java index da0beabd02..94fd9b049a 100644 --- a/app/src/main/java/com/sun/mail/handlers/text_plain.java +++ b/app/src/main/java/com/sun/mail/handlers/text_plain.java @@ -17,6 +17,8 @@ package com.sun.mail.handlers; import java.io.*; +import java.nio.charset.StandardCharsets; + import javax.activation.*; import javax.mail.internet.ContentType; import javax.mail.internet.MimeUtility; @@ -144,7 +146,10 @@ public class text_plain extends handler_base { String charset = ct.getParameter("charset"); if (charset == null) // If the charset parameter is absent, use US-ASCII. - charset = "us-ascii"; + if ("text/html".equalsIgnoreCase(ct.getBaseType())) + charset = StandardCharsets.UTF_8.name(); + else + charset = "us-ascii"; return MimeUtility.javaCharset(charset); } catch (Exception ex) { return null;