From ca2e96eb45bfc8fcd6873aad6b363f7b579d23ff Mon Sep 17 00:00:00 2001 From: morckx Date: Fri, 9 Sep 2016 22:32:46 +0200 Subject: [PATCH] Don't try to show invalid mail addresses in recipient selector (fixes #1607) --- .../fsck/k9/activity/compose/RecipientLoader.java | 14 ++++++++++---- .../java/com/fsck/k9/view/RecipientSelectView.java | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java index bd359924f..fa74de934 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientLoader.java @@ -15,7 +15,9 @@ import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Contacts.Data; +import android.util.Log; +import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.mail.Address; import com.fsck.k9.view.RecipientSelectView.Recipient; @@ -238,12 +240,16 @@ public class RecipientLoader extends AsyncTaskLoader> { } } - Uri photoUri = cursor.isNull(INDEX_PHOTO_URI) ? null : Uri.parse(cursor.getString(INDEX_PHOTO_URI)); Recipient recipient = new Recipient(name, email, addressLabel, contactId, lookupKey); - recipient.photoThumbnailUri = photoUri; + if(recipient.getAddress() != null) { // skip email addresses that could not be parsed + Uri photoUri = cursor.isNull(INDEX_PHOTO_URI) ? null : Uri.parse(cursor.getString(INDEX_PHOTO_URI)); - recipientMap.put(email, recipient); - recipients.add(recipient); + recipient.photoThumbnailUri = photoUri; + recipientMap.put(email, recipient); + recipients.add(recipient); + } else { + Log.w(K9.LOG_TAG, "Skipping invalid email address \"" + email + "\" of contact " + name + "."); + } } cursor.close(); diff --git a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java index 34066918c..bc4c61652 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java +++ b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java @@ -550,7 +550,11 @@ public class RecipientSelectView extends TokenCompleteTextView implem return address.getAddress(); } - public String getDisplayNameOrUnknown(Context context) { + public String getAddress() { + return address.getAddress(); + } + + public String getDisplayNameOrUnknown(Context context) { String displayName = getDisplayName(); if (displayName != null) { return displayName;