mirror of https://github.com/M66B/FairEmail.git
Parse email address again after double decoding
This commit is contained in:
parent
4f5b65e7e5
commit
720e10a44d
|
@ -470,12 +470,7 @@ public class MessageHelper {
|
||||||
if (address == null || address.length == 0)
|
if (address == null || address.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
try {
|
fix(address[0]);
|
||||||
address[0].setPersonal(decodeMime(address[0].getPersonal()));
|
|
||||||
address[0].setAddress(decodeMime(address[0].getAddress()));
|
|
||||||
} catch (UnsupportedEncodingException ex) {
|
|
||||||
Log.w(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return address[0];
|
return address[0];
|
||||||
}
|
}
|
||||||
|
@ -507,15 +502,29 @@ public class MessageHelper {
|
||||||
private static Address[] fix(Address[] addresses) {
|
private static Address[] fix(Address[] addresses) {
|
||||||
if (addresses != null)
|
if (addresses != null)
|
||||||
for (int i = 0; i < addresses.length; i++)
|
for (int i = 0; i < addresses.length; i++)
|
||||||
|
fix((InternetAddress) addresses[i]);
|
||||||
|
return addresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fix(InternetAddress address) {
|
||||||
try {
|
try {
|
||||||
((InternetAddress) addresses[i]).setPersonal(
|
String email = decodeMime(address.getAddress());
|
||||||
decodeMime(((InternetAddress) addresses[i]).getPersonal()));
|
String personal = decodeMime(address.getPersonal());
|
||||||
((InternetAddress) addresses[i]).setAddress(
|
try {
|
||||||
decodeMime(((InternetAddress) addresses[i]).getAddress()));
|
InternetAddress[] a = InternetAddress.parse(email);
|
||||||
|
if (a.length < 1)
|
||||||
|
throw new AddressException("empty");
|
||||||
|
String p = a[0].getPersonal();
|
||||||
|
address.setAddress(a[0].getAddress());
|
||||||
|
address.setPersonal(TextUtils.isEmpty(personal) ? p : personal + (p == null ? "" : " " + p));
|
||||||
|
} catch (AddressException ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
address.setAddress(email);
|
||||||
|
address.setPersonal(personal);
|
||||||
|
}
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
return addresses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getSubject() throws MessagingException {
|
String getSubject() throws MessagingException {
|
||||||
|
|
Loading…
Reference in New Issue