mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 16:43:26 +02:00
Fix UTF-8 subjects
This commit is contained in:
@@ -35,7 +35,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -614,6 +617,23 @@ public class MessageHelper {
|
||||
|
||||
String getSubject() throws MessagingException {
|
||||
String subject = imessage.getSubject();
|
||||
|
||||
// Fix UTF-8
|
||||
if (subject != null) {
|
||||
char[] kars = subject.toCharArray();
|
||||
byte[] bytes = new byte[kars.length];
|
||||
for (int i = 0; i < kars.length; i++)
|
||||
bytes[i] = (byte) kars[i];
|
||||
|
||||
try {
|
||||
CharsetDecoder cs = StandardCharsets.UTF_8.newDecoder();
|
||||
cs.decode(ByteBuffer.wrap(bytes));
|
||||
subject = new String(bytes, StandardCharsets.UTF_8);
|
||||
} catch (CharacterCodingException ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return decodeMime(subject);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user