From 43cd25cfa31030bc24516f74d7d0b86f93a8f3d3 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Mon, 1 Aug 2016 15:04:27 +0200 Subject: [PATCH] compose: show parse error for non-ascii characters in address --- .../src/main/java/com/fsck/k9/view/RecipientSelectView.java | 6 ++++++ k9mail/src/main/res/values/strings.xml | 2 ++ 2 files changed, 8 insertions(+) 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 e7dc78918..d3a6ac100 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java +++ b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java @@ -41,6 +41,7 @@ import com.fsck.k9.activity.compose.RecipientLoader; import com.fsck.k9.mail.Address; import com.fsck.k9.view.RecipientSelectView.Recipient; import com.tokenautocomplete.TokenCompleteTextView; +import org.apache.james.mime4j.util.CharsetUtil; public class RecipientSelectView extends TokenCompleteTextView implements LoaderCallbacks>, @@ -169,7 +170,12 @@ public class RecipientSelectView extends TokenCompleteTextView implem @Override protected Recipient defaultObject(String completionText) { Address[] parsedAddresses = Address.parse(completionText); + if (!CharsetUtil.isASCII(completionText)) { + setError(getContext().getString(R.string.recipient_error_non_ascii)); + return null; + } if (parsedAddresses.length == 0 || parsedAddresses[0].getAddress() == null) { + setError(getContext().getString(R.string.recipient_error_parse_failed)); return null; } diff --git a/k9mail/src/main/res/values/strings.xml b/k9mail/src/main/res/values/strings.xml index 4f2d9adea..f0d3dc249 100644 --- a/k9mail/src/main/res/values/strings.xml +++ b/k9mail/src/main/res/values/strings.xml @@ -1215,5 +1215,7 @@ Please submit bug reports, contribute new features and ask questions at This message was signed by an expired key! This message was signed by an insecure key! There was an error in this message\'s signature! + Special characters are currently not supported! + Error parsing address!