{'a+b@example.com', {user = 'a+b', domain = 'example.com', addr = 'a+b@example.com'}},
{'"a"@example.com', {user = 'a', domain = 'example.com', addr = 'a@example.com'}},
{'"a+b"@example.com', {user = 'a+b', domain = 'example.com', addr = 'a+b@example.com'}},
+ {'"<>"@example.com', {user = '<>', domain = 'example.com', addr = '<>@example.com'}},
+ {'<"<>"@example.com>', {user = '<>', domain = 'example.com', addr = '<>@example.com'}},
+ {'"\\""@example.com', {user = '"', domain = 'example.com', addr = '"@example.com'}},
+ {'"\\"abc"@example.com', {user = '"abc', domain = 'example.com', addr = '"abc@example.com'}},
+
}
each(function(case)
local st = ffi.C.rspamd_email_address_from_smtp(case[1], #case[1])
- assert_not_nil(st, "cannot parse " .. case[1])
+ assert_not_nil(st, "should be able to parse " .. case[1])
each(function(k, ex)
if k == 'user' then
end, case[2])
ffi.C.rspamd_email_address_unref(st)
end, cases_valid)
+
+ local cases_invalid = {
+ 'a',
+ 'a"b"@example.com',
+ 'a"@example.com',
+ '"a@example.com',
+ '<a@example.com',
+ 'a@example.com>',
+ '<a@.example.com>',
+ '<a@example.com.>',
+ '<a@example.com>>',
+ '<a@example.com><>',
+ }
+
+ each(function(case)
+ local st = ffi.C.rspamd_email_address_from_smtp(case, #case)
+
+ assert_nil(st, "should not be able to parse " .. case)
+ end, cases_invalid)
end)
end)