Workaround wrongly encoded headers

pull/161/head
M66B 5 years ago
parent b728eea4aa
commit b3e28071b3

@ -34,6 +34,7 @@ import java.io.FileReader;
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.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
@ -475,7 +476,22 @@ public class MessageHelper {
return null; return null;
header = new String(header.getBytes(StandardCharsets.ISO_8859_1)); header = new String(header.getBytes(StandardCharsets.ISO_8859_1));
return InternetAddress.parseHeader(header, false); Address[] addresses = InternetAddress.parseHeader(header, false);
for (Address address : addresses) {
InternetAddress iaddress = (InternetAddress) address;
iaddress.setAddress(decodeMime(iaddress.getAddress()));
String personal = iaddress.getPersonal();
if (personal != null) {
try {
iaddress.setPersonal(decodeMime(personal));
} catch (UnsupportedEncodingException ex) {
Log.w(ex);
}
}
}
return addresses;
} }
Address[] getFrom() throws MessagingException { Address[] getFrom() throws MessagingException {

Loading…
Cancel
Save