gint max_elements)
{
GPtrArray *res = src;
- gboolean seen_at = FALSE;
+ gboolean seen_at = FALSE, seen_obrace = FALSE;
const gchar *p = hdr, *end = hdr + len, *c = hdr, *t;
GString *ns, *cpy;
state = skip_spaces;
next_state = parse_name;
}
+ else if (*p == '@' && seen_obrace) {
+ seen_at = TRUE;
+ }
+ else if (*p == '<') {
+ seen_obrace = TRUE;
+ }
p ++;
break;
case parse_addr:
break;
case parse_quoted:
/* Unfinished quoted string or a comment */
+ /* If we have seen obrace + at, then we still can try to resolve address */
+ if (seen_at && seen_obrace) {
+ p = rspamd_memrchr (cpy->str, '<', cpy->len);
+ g_assert (p != NULL);
+ if (rspamd_email_address_check_and_add (p, end - p,
+ res, pool, ns, max_elements) == 0) {
+ if (res->len == 0) {
+ rspamd_email_address_add (pool, res, NULL, ns);
+ }
+ }
+ }
break;
default:
/* Do nothing */
local logger = require("rspamd_logger")
local ffi = require("ffi")
local util = require("rspamd_util")
- require "fun" ()
+ local fun = require "fun"
ffi.cdef[[
struct rspamd_email_address {
const char *raw;
}
- each(function(case)
+ fun.each(function(case)
test("Parse valid smtp addr: " .. case[1], function()
local st = ffi.C.rspamd_email_address_from_smtp(case[1], #case[1])
assert_not_nil(st, "should be able to parse " .. case[1])
- each(function(k, ex)
+ fun.each(function(k, ex)
if k == 'user' then
local str = ffi.string(st.user, st.user_len)
assert_equal(str, ex)
'<a@example.com><>',
}
- each(function(case)
+ fun.each(function(case)
test("Parse invalid smtp addr: " .. case, function()
local st = ffi.C.rspamd_email_address_from_smtp(case, #case)