case 'D':
/* Deliver-To */
if (g_ascii_strncasecmp (headern, DELIVER_TO_HEADER, sizeof (DELIVER_TO_HEADER) - 1) == 0) {
- task->deliver_to = memory_pool_fstrdup (task->task_pool, line);
+ task->deliver_to = escape_braces_addr_fstr (task->task_pool, line);
debug_task ("read deliver-to header, value: %s", task->deliver_to);
}
else {
case 'F':
/* from */
if (g_ascii_strncasecmp (headern, FROM_HEADER, sizeof (FROM_HEADER) - 1) == 0) {
- task->from = memory_pool_fstrdup (task->task_pool, line);
+ task->from = escape_braces_addr_fstr (task->task_pool, line);
debug_task ("read from header, value: %s", task->from);
}
else {
case 'R':
/* rcpt */
if (g_ascii_strncasecmp (headern, RCPT_HEADER, sizeof (RCPT_HEADER) - 1) == 0) {
- tmp = memory_pool_fstrdup (task->task_pool, line);
+ tmp = escape_braces_addr_fstr (task->task_pool, line);
task->rcpt = g_list_prepend (task->rcpt, tmp);
debug_task ("read rcpt header, value: %s", tmp);
}
for(j = 0; j < n; j++) {
it_val = json_array_get(cur_nm, j);
if (it_val && json_is_string (it_val)) {
- g_hash_table_insert (cur_settings->whitelist,
+ if (strlen (json_string_value (it_val)) > 0) {
+ g_hash_table_insert (cur_settings->whitelist,
g_strdup (json_string_value (it_val)), g_strdup (json_string_value (it_val)));
+ }
}
}
for(j = 0; j < n; j++) {
it_val = json_array_get(cur_nm, j);
if (it_val && json_is_string (it_val)) {
- g_hash_table_insert (cur_settings->blacklist,
+ if (strlen (json_string_value (it_val)) > 0) {
+ g_hash_table_insert (cur_settings->blacklist,
g_strdup (json_string_value (it_val)), g_strdup (json_string_value (it_val)));
+ }
}
}
free_task (task, FALSE);
}
+gchar *
+escape_braces_addr_fstr (memory_pool_t *pool, f_str_t *in)
+{
+ gint len = 0;
+ gchar *res, *orig, *p;
+
+ orig = in->begin;
+ while ((g_ascii_isspace (*orig) || *orig == '<') && orig - in->begin < in->len) {
+ orig ++;
+ }
+
+ p = orig;
+ while ((!g_ascii_isspace (*p) && *p != '>') && p - in->begin < in->len) {
+ p ++;
+ len ++;
+ }
+
+ res = memory_pool_alloc (pool, len + 1);
+ rspamd_strlcpy (res, orig, len + 1);
+
+ return res;
+}
+
/*
* vi:ts=4
*/
#include "radix.h"
#include "statfile.h"
#include "printf.h"
+#include "fstring.h"
struct config_file;
struct rspamd_main;
*/
enum process_type str_to_process (const gchar *str);
+/*
+ * Strip <> from email address
+ */
+gchar * escape_braces_addr_fstr (memory_pool_t *pool, f_str_t *in);
+
/*
* Convert milliseconds to timeval fields
*/