Merge pull request #2885 from jyn514/issue-2846
Prevent crash when parsing invalid base64 email address
This commit is contained in:
commit
0a6ef2b70f
2 changed files with 9 additions and 2 deletions
|
@ -2,12 +2,14 @@
|
|||
package com.fsck.k9.mail;
|
||||
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.james.mime4j.MimeException;
|
||||
import org.apache.james.mime4j.codec.DecodeMonitor;
|
||||
import org.apache.james.mime4j.codec.EncoderUtil;
|
||||
import org.apache.james.mime4j.dom.address.Mailbox;
|
||||
import org.apache.james.mime4j.dom.address.MailboxList;
|
||||
|
@ -30,7 +32,6 @@ public class Address implements Serializable {
|
|||
|
||||
private String mPersonal;
|
||||
|
||||
|
||||
public Address(Address address) {
|
||||
mAddress = address.mAddress;
|
||||
mPersonal = address.mPersonal;
|
||||
|
@ -142,7 +143,7 @@ public class Address implements Serializable {
|
|||
}
|
||||
List<Address> addresses = new ArrayList<>();
|
||||
try {
|
||||
MailboxList parsedList = DefaultAddressParser.DEFAULT.parseAddressList(addressList).flatten();
|
||||
MailboxList parsedList = DefaultAddressParser.DEFAULT.parseAddressList(addressList, DecodeMonitor.SILENT).flatten();
|
||||
|
||||
for (int i = 0, count = parsedList.size(); i < count; i++) {
|
||||
Mailbox mailbox = parsedList.get(i);
|
||||
|
|
|
@ -180,4 +180,10 @@ public class AddressTest {
|
|||
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesInvalidBase64Encoding() throws Exception {
|
||||
Address address = Address.parse("=?utf-8?b?invalid#?= <oops@example.com>")[0];
|
||||
assertEquals("oops@example.com", address.getAddress());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue