Added check for duplicate addresses

pull/187/head
M66B 5 years ago
parent 9f1d41ea42
commit 19d5da3280

@ -1055,6 +1055,7 @@ Too large messages and triggering the spam filter of an email server are the mos
* The attachment size limit for Yahoo [is 25 MB](https://help.yahoo.com/kb/SLN5673.html) * The attachment size limit for Yahoo [is 25 MB](https://help.yahoo.com/kb/SLN5673.html)
* *554 5.7.1 Service unavailable; Client host xxx.xxx.xxx.xxx blocked*, please [see here](https://docs.gandi.net/en/gandimail/faq/error_types/554_5_7_1_service_unavailable.html) * *554 5.7.1 Service unavailable; Client host xxx.xxx.xxx.xxx blocked*, please [see here](https://docs.gandi.net/en/gandimail/faq/error_types/554_5_7_1_service_unavailable.html)
* *501 Syntax error - line too long* is often caused by using a long Autocrypt header * *501 Syntax error - line too long* is often caused by using a long Autocrypt header
* *503 5.5.0 Recipient already specified* mostly means that an address is being used both as TO and CC address
**Gmail errors** **Gmail errors**

@ -4502,6 +4502,23 @@ public class FragmentCompose extends FragmentBase {
checkAddress(ato, context); checkAddress(ato, context);
checkAddress(acc, context); checkAddress(acc, context);
checkAddress(abcc, context); checkAddress(abcc, context);
List<String> all = new ArrayList<>();
List<String> dup = new ArrayList<>();
for (InternetAddress a : Helper.concat(Helper.concat(ato, acc), abcc)) {
String email = a.getAddress();
if (TextUtils.isEmpty(email))
continue;
if (all.contains(a.getAddress()))
dup.add(email);
else
all.add(email);
}
if (dup.size() > 0)
throw new AddressException(context.getString(
R.string.title_address_duplicate,
TextUtils.join(", ", dup)));
} catch (AddressException ex) { } catch (AddressException ex) {
args.putString("address_error", ex.getMessage()); args.putString("address_error", ex.getMessage());
} }

@ -1564,6 +1564,17 @@ public class Helper {
return result; return result;
} }
@SuppressWarnings("unchecked")
public static <T> T[] concat(T[] a, T[] b) {
if (a == null)
a = (T[]) new Object[0];
if (b == null)
b = (T[]) new Object[0];
T[] both = Arrays.copyOf(a, a.length + b.length);
System.arraycopy(b, 0, both, a.length, b.length);
return both;
}
static boolean equal(String[] a1, String[] a2) { static boolean equal(String[] a1, String[] a2) {
if (a1 == null && a2 == null) if (a1 == null && a2 == null)
return true; return true;

@ -487,7 +487,7 @@ public class MessageHelper {
if (existing != null) if (existing != null)
result.addAll(Arrays.asList(existing)); result.addAll(Arrays.asList(existing));
Address[] all = imessage.getAllRecipients(); Address[] all = imessage.getAllRecipients(); // to, cc, bcc
Address[] addresses = convertAddress(InternetAddress.parse(email), identity); Address[] addresses = convertAddress(InternetAddress.parse(email), identity);
for (Address address : addresses) { for (Address address : addresses) {
boolean found = false; boolean found = false;

@ -664,6 +664,7 @@
<string name="title_no_name">Name missing</string> <string name="title_no_name">Name missing</string>
<string name="title_no_email">Email address missing</string> <string name="title_no_email">Email address missing</string>
<string name="title_email_invalid">Email address invalid: \'%1$s\'</string> <string name="title_email_invalid">Email address invalid: \'%1$s\'</string>
<string name="title_address_duplicate">Address \'%1$s\' duplicate</string>
<string name="title_address_parse_error">Address \'%1$s\' invalid: %2$s</string> <string name="title_address_parse_error">Address \'%1$s\' invalid: %2$s</string>
<string name="title_no_account">Account missing</string> <string name="title_no_account">Account missing</string>
<string name="title_no_host">Host name missing</string> <string name="title_no_host">Host name missing</string>

Loading…
Cancel
Save