diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-04 16:03:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-04 16:03:34 +0000 |
commit | 3548785ebdc0e9a9aefc782c85bccb08456e8f3f (patch) | |
tree | 7577414613aa45d28c7444eb5ef9ca39ee9b47c1 /test | |
parent | 80cb50dea482246656a49e54a915bdc343ffe897 (diff) | |
download | rspamd-3548785ebdc0e9a9aefc782c85bccb08456e8f3f.tar.gz rspamd-3548785ebdc0e9a9aefc782c85bccb08456e8f3f.zip |
[Fix] Another story about char sign
Ragel still produces a wrong state machine if `const char *` is used
for characters representation that are actually utf8.
This PR changes all types to `unsigned char *` for consistency.
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/unit/smtp_addr.lua | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/test/lua/unit/smtp_addr.lua b/test/lua/unit/smtp_addr.lua index 2cb7755f8..ffabd838a 100644 --- a/test/lua/unit/smtp_addr.lua +++ b/test/lua/unit/smtp_addr.lua @@ -5,7 +5,7 @@ context("SMTP address check functions", function() local ffi = require("ffi") local util = require("rspamd_util") local fun = require "fun" - ffi.cdef[[ + ffi.cdef [[ struct rspamd_email_address { const char *raw; const char *addr; @@ -24,29 +24,30 @@ context("SMTP address check functions", function() ]] local cases_valid = { - {'<>', {addr = ''}}, - {'<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'}}, - {'<a-b@ex-ample.com>', {user = 'a-b', domain = 'ex-ample.com', addr = 'a-b@ex-ample.com'}}, - {'1367=dec2a6ce-81bd-4fa9-ad02-ec5956466c04=9=1655370@example.220-volt.ru', - {user = '1367=dec2a6ce-81bd-4fa9-ad02-ec5956466c04=9=1655370', - domain = 'example.220-volt.ru', - addr = '1367=dec2a6ce-81bd-4fa9-ad02-ec5956466c04=9=1655370@example.220-volt.ru'}}, - {'notification+kjdm---m7wwd@facebookmail.com', {user = 'notification+kjdm---m7wwd'}}, - {'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'}}, - {'"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'}}, - {'<@domain1,@domain2,@domain3:abc@example.com>', - {user = 'abc', domain = 'example.com', addr = 'abc@example.com'}}, + { '<>', { addr = '' } }, + { '<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' } }, + { '<a-b@ex-ample.com>', { user = 'a-b', domain = 'ex-ample.com', addr = 'a-b@ex-ample.com' } }, + { '1367=dec2a6ce-81bd-4fa9-ad02-ec5956466c04=9=1655370@example.220-volt.ru', + { user = '1367=dec2a6ce-81bd-4fa9-ad02-ec5956466c04=9=1655370', + domain = 'example.220-volt.ru', + addr = '1367=dec2a6ce-81bd-4fa9-ad02-ec5956466c04=9=1655370@example.220-volt.ru' } }, + { 'notification+kjdm---m7wwd@facebookmail.com', { user = 'notification+kjdm---m7wwd' } }, + { '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' } }, + { '"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' } }, + { '<@domain1,@domain2,@domain3:abc@example.com>', + { user = 'abc', domain = 'example.com', addr = 'abc@example.com' } }, + -- SMTP UTF8 + { 'ñ@example.com', { user = 'ñ', domain = 'example.com' } } } - 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]) @@ -69,17 +70,17 @@ context("SMTP address check functions", function() end) 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><>', - } + 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><>', + } fun.each(function(case) test("Parse invalid smtp addr: " .. case, function() @@ -95,7 +96,7 @@ context("SMTP address check functions", function() local niter = 100000 local total = 0 - for i = 1,niter do + for i = 1, niter do local ncase = string.format(case, i) local t1 = util.get_ticks() local st = ffi.C.rspamd_email_address_from_smtp(ncase, #ncase) |