Workaround double encoded subjects

This commit is contained in:
M66B 2019-01-01 14:58:51 +01:00
parent 778c71cdf1
commit 47fed9180b
2 changed files with 15 additions and 1 deletions

View File

@ -54,6 +54,7 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.internet.ParseException;
public class MessageHelper {
@ -435,6 +436,19 @@ public class MessageHelper {
return null;
}
String getSubject() throws MessagingException, UnsupportedEncodingException {
String subject = imessage.getSubject();
if (subject != null && subject.indexOf("=?") >= 0) {
String prev;
do {
prev = subject;
subject = MimeUtility.decodeText(subject);
}
while (!subject.equals(prev));
}
return subject;
}
Integer getSize() throws MessagingException {
int size = imessage.getSize();
return (size < 0 ? null : size);

View File

@ -2379,7 +2379,7 @@ public class ServiceSynchronize extends LifecycleService {
message.cc = helper.getCc();
message.bcc = helper.getBcc();
message.reply = helper.getReply();
message.subject = imessage.getSubject();
message.subject = helper.getSubject();
message.size = helper.getSize();
message.content = false;
message.received = imessage.getReceivedDate().getTime();