]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Support recipients separated by commas
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 19 Apr 2018 14:00:48 +0000 (15:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 19 Apr 2018 14:00:48 +0000 (15:00 +0100)
src/libserver/protocol.c

index c7e693e31207cb603e6f28e7c37b47acbc90125d..7f12e388394196a5e46e7521181ade7dfd9cbe67 100644 (file)
@@ -316,19 +316,39 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
                        case 'r':
                        case 'R':
                                IF_HEADER (RCPT_HEADER) {
-                                       addr = rspamd_email_address_from_smtp (hv->str, hv->len);
+                                       const gchar *p, *end;
+                                       gsize cur_len;
 
-                                       if (addr) {
-                                               if (task->rcpt_envelope == NULL) {
-                                                       task->rcpt_envelope = g_ptr_array_sized_new (2);
+                                       p = hv->str;
+                                       end = p + hv->len;
+
+                                       while (p < end) {
+                                               cur_len = rspamd_memcspn (p, ",", end - p);
+
+                                               if (cur_len > 0) {
+                                                       addr = rspamd_email_address_from_smtp (p, cur_len);
+
+                                                       if (addr) {
+                                                               if (task->rcpt_envelope == NULL) {
+                                                                       task->rcpt_envelope = g_ptr_array_sized_new (
+                                                                                       2);
+                                                               }
+
+                                                               g_ptr_array_add (task->rcpt_envelope, addr);
+                                                       } else {
+                                                               msg_err_protocol ("bad rcpt header: '%T'",
+                                                                               &h->value);
+                                                               task->flags |= RSPAMD_TASK_FLAG_BROKEN_HEADERS;
+                                                       }
+
+                                                       p += cur_len;
                                                }
 
-                                               g_ptr_array_add (task->rcpt_envelope, addr);
-                                       }
-                                       else {
-                                               msg_err_protocol ("bad rcpt header: '%T'", &h->value);
-                                               task->flags |= RSPAMD_TASK_FLAG_BROKEN_HEADERS;
+                                               while (p < end && *p == ',') {
+                                                       p ++;
+                                               }
                                        }
+
                                        msg_debug_protocol ("read rcpt header, value: %V", hv);
                                }
                                else {