mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-04 08:08:16 +02:00
Conditionally convert address header/subject charset
This commit is contained in:
@@ -854,7 +854,10 @@ public class MessageHelper {
|
||||
if (header == null)
|
||||
return null;
|
||||
|
||||
header = new String(header.getBytes(StandardCharsets.ISO_8859_1));
|
||||
if (!Helper.isUTF8(header)) {
|
||||
Log.w("Converting header '" + name + "' to ISO8859-1");
|
||||
header = new String(header.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
Address[] addresses = InternetAddress.parseHeader(header, false);
|
||||
|
||||
for (Address address : addresses) {
|
||||
@@ -995,7 +998,10 @@ public class MessageHelper {
|
||||
if (subject == null)
|
||||
return null;
|
||||
|
||||
subject = new String(subject.getBytes(StandardCharsets.ISO_8859_1));
|
||||
if (!Helper.isUTF8(subject)) {
|
||||
Log.w("Converting subject to ISO8859-1");
|
||||
subject = new String(subject.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
subject = subject.replaceAll("\\?=\\r?\\n\\s+=\\?", "\\?==\\?");
|
||||
subject = MimeUtility.unfold(subject);
|
||||
subject = decodeMime(subject);
|
||||
|
||||
Reference in New Issue
Block a user