Fixed identity validation

master
M66B 2 weeks ago
parent 5ff6634a6d
commit 0a541b8256

@ -945,7 +945,7 @@ public class FragmentIdentity extends FragmentBase {
if (synchronize && TextUtils.isEmpty(password) && !insecure && certificate == null && !should)
throw new IllegalArgumentException(context.getString(R.string.title_no_password));
if (!TextUtils.isEmpty(replyto) && !should) {
if (!TextUtils.isEmpty(replyto) && !MessageHelper.hasPlaceholder(replyto) && !should) {
try {
InternetAddress[] addresses = InternetAddress.parse(replyto);
if (addresses.length != 1)
@ -956,7 +956,7 @@ public class FragmentIdentity extends FragmentBase {
}
}
if (!TextUtils.isEmpty(cc) && !should)
if (!TextUtils.isEmpty(cc) && !MessageHelper.hasPlaceholder(cc) && !should)
try {
for (InternetAddress address : InternetAddress.parse(cc))
address.validate();
@ -964,7 +964,7 @@ public class FragmentIdentity extends FragmentBase {
throw new IllegalArgumentException(context.getString(R.string.title_email_invalid, cc));
}
if (!TextUtils.isEmpty(bcc) && !should)
if (!TextUtils.isEmpty(bcc) && !MessageHelper.hasPlaceholder(bcc) && !should)
try {
for (InternetAddress address : InternetAddress.parse(bcc))
address.validate();

@ -858,9 +858,13 @@ public class MessageHelper {
return new InternetAddress(email, name, StandardCharsets.UTF_8.name());
}
public static boolean hasPlaceholder(String address) {
return (!TextUtils.isEmpty(address) &&
(address.contains("$from$")) || address.contains("$user$") || address.contains("$domain$") || address.contains("$extra$"));
}
static String replacePlaceholders(String address, EntityMessage message, EntityIdentity identity) throws UnsupportedEncodingException {
if (!TextUtils.isEmpty(address) &&
(address.contains("$from$")) || address.contains("$user$") || address.contains("$domain$") || address.contains("$extra$")) {
if (hasPlaceholder(address)) {
Address from = getFrom(message, identity);
if (from instanceof InternetAddress) {
String email = ((InternetAddress) from).getAddress();

Loading…
Cancel
Save