diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-04-25 13:21:51 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-04-25 13:21:51 +0100 |
commit | a03b2c328b0c9cb332527adb584b6e3496de5e46 (patch) | |
tree | a46ff1eabb22c94e76324805be0d38d6ae8efa72 /src/libmime/email_addr.c | |
parent | d21fdd376f883510ae2bf5de7307eb59d84cb614 (diff) | |
download | rspamd-a03b2c328b0c9cb332527adb584b6e3496de5e46.tar.gz rspamd-a03b2c328b0c9cb332527adb584b6e3496de5e46.zip |
[Fix] Deal with 8bit characters in email addresses
Diffstat (limited to 'src/libmime/email_addr.c')
-rw-r--r-- | src/libmime/email_addr.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/libmime/email_addr.c b/src/libmime/email_addr.c index c857794c8..59e99f531 100644 --- a/src/libmime/email_addr.c +++ b/src/libmime/email_addr.c @@ -169,7 +169,8 @@ static gboolean rspamd_email_address_parse_heuristic (const char *data, size_t len, struct rspamd_email_address *addr) { - const gchar *p = data; + const gchar *p = data, *at = NULL, *end = data + len; + gboolean ret = FALSE; memset (addr, 0, sizeof (*addr)); @@ -179,19 +180,36 @@ rspamd_email_address_parse_heuristic (const char *data, size_t len, addr->addr = p + 1; addr->raw = p; addr->raw_len = len; + ret = TRUE; - return TRUE; + p = p + 1; + len = addr->addr_len; + end = p + len; } else if (len > 0) { addr->addr = p; addr->addr_len = len; addr->raw = p; addr->raw_len = len; + ret = TRUE; + } + + if (ret) { + at = memchr (p, '@', len); + + if (at != NULL && at + 1 < end) { + addr->domain = at + 1; + addr->domain_len = end - (at + 1); + addr->user = p; + addr->user_len = at - p; + } - return TRUE; + if (rspamd_str_has_8bit (p, len)) { + addr->flags |= RSPAMD_EMAIL_ADDR_HAS_8BIT; + } } - return FALSE; + return ret; } GPtrArray * @@ -329,6 +347,9 @@ rspamd_email_address_from_mime (rspamd_mempool_t *pool, state = skip_spaces; next_state = parse_name; } + else if (*p == '@') { + seen_at = TRUE; + } p ++; break; case skip_spaces: |