Fixed issue 2846
Skip invalid input; parse strictly otherwise. See [issue](https://github.com/k9mail/k-9/issues/2846) for details.
This commit is contained in:
parent
d696723023
commit
ddcf1e257e
2 changed files with 9 additions and 2 deletions
|
@ -2,12 +2,14 @@
|
||||||
package com.fsck.k9.mail;
|
package com.fsck.k9.mail;
|
||||||
|
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.james.mime4j.MimeException;
|
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.codec.EncoderUtil;
|
||||||
import org.apache.james.mime4j.dom.address.Mailbox;
|
import org.apache.james.mime4j.dom.address.Mailbox;
|
||||||
import org.apache.james.mime4j.dom.address.MailboxList;
|
import org.apache.james.mime4j.dom.address.MailboxList;
|
||||||
|
@ -30,7 +32,6 @@ public class Address implements Serializable {
|
||||||
|
|
||||||
private String mPersonal;
|
private String mPersonal;
|
||||||
|
|
||||||
|
|
||||||
public Address(Address address) {
|
public Address(Address address) {
|
||||||
mAddress = address.mAddress;
|
mAddress = address.mAddress;
|
||||||
mPersonal = address.mPersonal;
|
mPersonal = address.mPersonal;
|
||||||
|
@ -142,7 +143,7 @@ public class Address implements Serializable {
|
||||||
}
|
}
|
||||||
List<Address> addresses = new ArrayList<>();
|
List<Address> addresses = new ArrayList<>();
|
||||||
try {
|
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++) {
|
for (int i = 0, count = parsedList.size(); i < count; i++) {
|
||||||
Mailbox mailbox = parsedList.get(i);
|
Mailbox mailbox = parsedList.get(i);
|
||||||
|
|
|
@ -180,4 +180,10 @@ public class AddressTest {
|
||||||
|
|
||||||
assertNull(result);
|
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