Fixed protected header encoding

This commit is contained in:
M66B 2020-11-24 22:20:03 +01:00
parent 3af2de08f8
commit eab9dd1fd6
2 changed files with 10 additions and 2 deletions

View File

@ -155,6 +155,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
@ -194,6 +195,7 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.internet.ParseException; import javax.mail.internet.ParseException;
import javax.mail.util.ByteArrayDataSource; import javax.mail.util.ByteArrayDataSource;
@ -2360,7 +2362,13 @@ public class FragmentCompose extends FragmentBase {
ContentType ct = new ContentType(type); ContentType ct = new ContentType(type);
ct.setParameter("protected-headers", "v1"); ct.setParameter("protected-headers", "v1");
setHeader("Content-Type", ct.toString()); setHeader("Content-Type", ct.toString());
setHeader("Subject", draft.subject == null ? "" : draft.subject); String subject = draft.subject == null ? "" : draft.subject;
try {
setHeader("Subject", MimeUtility.encodeWord(subject));
} catch (UnsupportedEncodingException ex) {
Log.e(ex);
setHeader("Subject", subject);
}
} }
}; };

View File

@ -2336,7 +2336,7 @@ public class MessageHelper {
if ("v1".equals(ct.getParameter("protected-headers"))) { if ("v1".equals(ct.getParameter("protected-headers"))) {
String[] subject = part.getHeader("subject"); String[] subject = part.getHeader("subject");
if (subject != null && subject.length != 0) if (subject != null && subject.length != 0)
parts.protected_subject = subject[0]; parts.protected_subject = decodeMime(subject[0]);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);