mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 02:07:12 +00:00
Improve rule address validation
This commit is contained in:
parent
146f2bb8a8
commit
55ad97ad4d
1 changed files with 8 additions and 2 deletions
|
@ -539,8 +539,14 @@ public class EntityRule {
|
||||||
String to = jargs.optString("to");
|
String to = jargs.optString("to");
|
||||||
if (TextUtils.isEmpty(to))
|
if (TextUtils.isEmpty(to))
|
||||||
throw new IllegalArgumentException(context.getString(R.string.title_rule_answer_missing));
|
throw new IllegalArgumentException(context.getString(R.string.title_rule_answer_missing));
|
||||||
else if (!Helper.EMAIL_ADDRESS.matcher(to).matches())
|
else
|
||||||
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, to));
|
try {
|
||||||
|
InternetAddress[] addresses = MessageHelper.parseAddresses(context, to);
|
||||||
|
if (addresses == null || addresses.length == 0)
|
||||||
|
throw new IllegalArgumentException(context.getString(R.string.title_no_email));
|
||||||
|
} catch (AddressException ex) {
|
||||||
|
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, to));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
EntityAnswer answer = db.answer().getAnswer(aid);
|
EntityAnswer answer = db.answer().getAnswer(aid);
|
||||||
if (answer == null)
|
if (answer == null)
|
||||||
|
|
Loading…
Reference in a new issue