return ret;
}
-static inline gboolean
+static inline int
rspamd_email_address_check_and_add (const gchar *start, gsize len,
GPtrArray *res,
rspamd_mempool_t *pool,
max_elements,
ns);
- return FALSE;
+ return -1;
}
/* The whole email is likely address */
len, &addr)) {
rspamd_email_address_add (pool, res, &addr, ns);
- return TRUE;
+ return 1;
}
else {
- return FALSE;
+ return 0;
}
}
- return TRUE;
+ return 1;
}
GPtrArray *
t --;
}
- if (!rspamd_email_address_check_and_add (c, t - c + 1,
- res, pool, ns, max_elements)) {
+ int check = rspamd_email_address_check_and_add (c, t - c + 1,
+ res, pool, ns, max_elements);
+
+ if (check == 0 && res->len == 0) {
+ /* Insert fake address */
rspamd_email_address_add (pool, res, NULL, ns);
}
+ else if (check != 1) {
+ goto end;
+ }
/* Cleanup for the next use */
g_string_set_size (ns, 0);
break;
case parse_addr:
if (*p == '>') {
- if (!rspamd_email_address_check_and_add (c, p - c + 1,
- res, pool, ns, max_elements)) {
+ int check = rspamd_email_address_check_and_add (c, p - c + 1,
+ res, pool, ns, max_elements);
+ if (check == 0 && res->len == 0) {
+ /* Insert a fake address */
rspamd_email_address_add (pool, res, NULL, ns);
}
+ else if (check != 1) {
+ goto end;
+ }
/* Cleanup for the next use */
g_string_set_size (ns, 0);
if (p > c) {
if (seen_at) {
/* The whole email is likely address */
- if (!rspamd_email_address_check_and_add (c, p - c,
- res, pool, ns, max_elements)) {
- if (res->len == 0) {
- rspamd_email_address_add (pool, res, NULL, ns);
- }
+ int check = rspamd_email_address_check_and_add (c, p - c,
+ res, pool, ns, max_elements);
+ if (check == 0 && res->len == 0) {
+ /* Insert a fake address */
+ rspamd_email_address_add (pool, res, NULL, ns);
+ }
+ else if (check != 1) {
+ goto end;
}
} else {
/* No @ seen */
break;
case parse_addr:
if (p > c) {
- if (!rspamd_email_address_check_and_add (c, p - c,
- res, pool, ns, max_elements)) {
+ if (rspamd_email_address_check_and_add (c, p - c,
+ res, pool, ns, max_elements) == 0) {
if (res->len == 0) {
rspamd_email_address_add (pool, res, NULL, ns);
}
/* Do nothing */
break;
}
-
+end:
rspamd_mempool_notify_alloc (pool, cpy->len);
g_string_free (ns, TRUE);