aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/email_addr.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-22 17:05:03 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-22 17:05:03 +0000
commit3b442dfa9726d3991213a3e3db894b462bcae479 (patch)
tree8a16187a5d58876b9170cb7ef190bf2ff4cb3816 /src/libmime/email_addr.c
parentae6846779130c75fda82bee1692ecd4ce169fd06 (diff)
downloadrspamd-3b442dfa9726d3991213a3e3db894b462bcae479.tar.gz
rspamd-3b442dfa9726d3991213a3e3db894b462bcae479.zip
[Minor] More fixes to parsing of mime addresses
Diffstat (limited to 'src/libmime/email_addr.c')
-rw-r--r--src/libmime/email_addr.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libmime/email_addr.c b/src/libmime/email_addr.c
index 309382462..1b97a842c 100644
--- a/src/libmime/email_addr.c
+++ b/src/libmime/email_addr.c
@@ -146,6 +146,7 @@ rspamd_email_address_add (rspamd_mempool_t *pool,
if (name->len > 0) {
elt->name = rspamd_mime_header_decode (pool, name->str, name->len);
+ elt->name_len = strlen (elt->name);
}
g_ptr_array_add (ar, elt);
@@ -181,12 +182,13 @@ rspamd_email_address_from_mime (rspamd_mempool_t *pool,
if (*p == '"') {
/* We need to strip last spaces and update `ns` */
if (p > c) {
- t = p;
+ t = p - 1;
+
while (t > c && g_ascii_isspace (*t)) {
t --;
}
- g_string_append_len (ns, c, t - c);
+ g_string_append_len (ns, c, t - c + 1);
}
state = parse_quoted;
@@ -194,12 +196,13 @@ rspamd_email_address_from_mime (rspamd_mempool_t *pool,
}
else if (*p == '<') {
if (p > c) {
- t = p;
+ t = p - 1;
+
while (t > c && g_ascii_isspace (*t)) {
t --;
}
- g_string_append_len (ns, c, t - c);
+ g_string_append_len (ns, c, t - c + 1);
}
c = p;
@@ -212,11 +215,12 @@ rspamd_email_address_from_mime (rspamd_mempool_t *pool,
* e.g. Some name name@domain.com
*/
t = p;
+
while (t > c && g_ascii_isspace (*t)) {
t --;
}
- rspamd_smtp_addr_parse (c, t - c, &addr);
+ rspamd_smtp_addr_parse (c, t - c + 1, &addr);
if (addr.flags & RSPAMD_EMAIL_ADDR_VALID) {
rspamd_email_address_add (pool, res, &addr, ns);
@@ -275,7 +279,7 @@ rspamd_email_address_from_mime (rspamd_mempool_t *pool,
case parse_name:
case parse_addr:
if (p > c) {
- rspamd_smtp_addr_parse (c, p - c + 1, &addr);
+ rspamd_smtp_addr_parse (c, p - c, &addr);
if (addr.flags & RSPAMD_EMAIL_ADDR_VALID) {
rspamd_email_address_add (pool, res, &addr, ns);