Fixed subject decode workaround

This commit is contained in:
M66B 2019-01-21 17:46:51 +00:00
parent 2fa0b0564b
commit 7d697046ce
1 changed files with 14 additions and 8 deletions

View File

@ -496,15 +496,21 @@ public class MessageHelper {
String getSubject() throws MessagingException, UnsupportedEncodingException { String getSubject() throws MessagingException, UnsupportedEncodingException {
String subject = imessage.getSubject(); String subject = imessage.getSubject();
if (subject != null && subject.contains("=?")) { if (subject == null)
String prev; return subject;
do {
prev = subject; int i = 0;
subject = MimeUtility.decodeText(subject); int s = subject.indexOf("=?", i);
Log.i("Mime decode " + prev + " -> " + subject); int e = subject.indexOf("?=", i);
} while (s >= 0 && e >= 0 && i < subject.length()) {
while (!subject.equals(prev)); String decode = subject.substring(s, e + 2);
String decoded = MimeUtility.decodeText(decode);
subject = subject.substring(0, i) + decoded + subject.substring(e + 2);
i += decoded.length();
s = subject.indexOf("=?", i);
e = subject.indexOf("?=", i);
} }
return subject; return subject;
} }