aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-07 17:24:51 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-07 17:24:51 +0000
commit841dbfe275d0863c272420ac718ea5f478552c4d (patch)
tree46efe0fdcb786603cc4bc34e6f5979c07730c4ef
parent1e0caa55d3f1910973694d6481a13c689212a1cd (diff)
downloadrspamd-841dbfe275d0863c272420ac718ea5f478552c4d.tar.gz
rspamd-841dbfe275d0863c272420ac718ea5f478552c4d.zip
[Minor] Fix `with` parsing
-rw-r--r--src/libmime/mime_headers.c12
-rw-r--r--test/lua/unit/received.lua19
2 files changed, 26 insertions, 5 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 20c1e2ee9..ca44c4765 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -1427,7 +1427,7 @@ rspamd_smtp_received_parse (struct rspamd_task *task,
RSPAMD_FTOK_ASSIGN (&t2, "esmtp");
- if (rspamd_ftok_starts_with (&t1, &t2) == 0) {
+ if (rspamd_ftok_starts_with (&t1, &t2)) {
/*
* esmtp, esmtps, esmtpsa
*/
@@ -1440,6 +1440,7 @@ rspamd_smtp_received_parse (struct rspamd_task *task,
rh->type = RSPAMD_RECEIVED_ESMTPS;
rh->flags |= RSPAMD_RECEIVED_FLAG_SSL;
}
+ continue;
}
else if (t1.len == t2.len + 2) {
if (t1.begin[t2.len - 1] == 's' &&
@@ -1448,9 +1449,11 @@ rspamd_smtp_received_parse (struct rspamd_task *task,
rh->flags |= RSPAMD_RECEIVED_FLAG_AUTHENTICATED;
rh->flags |= RSPAMD_RECEIVED_FLAG_SSL;
}
+ continue;
}
else if (t1.len == t2.len) {
rh->type = RSPAMD_RECEIVED_ESMTP;
+ continue;
}
}
@@ -1458,23 +1461,26 @@ rspamd_smtp_received_parse (struct rspamd_task *task,
if (rspamd_ftok_cmp (&t1, &t2) == 0) {
rh->type = RSPAMD_RECEIVED_LMTP;
+ continue;
}
RSPAMD_FTOK_ASSIGN (&t2, "imap");
if (rspamd_ftok_cmp (&t1, &t2) == 0) {
rh->type = RSPAMD_RECEIVED_IMAP;
+ continue;
}
RSPAMD_FTOK_ASSIGN (&t2, "local");
if (rspamd_ftok_cmp (&t1, &t2) == 0) {
rh->type = RSPAMD_RECEIVED_LOCAL;
+ continue;
}
RSPAMD_FTOK_ASSIGN (&t2, "http");
- if (rspamd_ftok_starts_with (&t1, &t2) == 0) {
+ if (rspamd_ftok_starts_with (&t1, &t2)) {
if (t1.len == t2.len + 1) {
if (t1.begin[t2.len] == 's') {
rh->type = RSPAMD_RECEIVED_HTTP;
@@ -1484,6 +1490,8 @@ rspamd_smtp_received_parse (struct rspamd_task *task,
else if (t1.len == t2.len) {
rh->type = RSPAMD_RECEIVED_HTTP;
}
+
+ continue;
}
}
diff --git a/test/lua/unit/received.lua b/test/lua/unit/received.lua
index 75fd3701c..b7a425785 100644
--- a/test/lua/unit/received.lua
+++ b/test/lua/unit/received.lua
@@ -25,6 +25,19 @@ context("Received headers parser", function()
]]
local cases = {
+ {[[from server.chat-met-vreemden.nl (unknown [IPv6:2a01:7c8:aab6:26d:5054:ff:fed1:1da2])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (Client did not present a certificate)
+ by mx1.freebsd.org (Postfix) with ESMTPS id CF0171862
+ for <test@example.com>; Mon, 6 Jul 2015 09:01:20 +0000 (UTC)
+ (envelope-from upwest201diana@outlook.com)]],
+ {
+ real_ip = '2a01:7c8:aab6:26d:5054:ff:fed1:1da2',
+ from_hostname = 'server.chat-met-vreemden.nl',
+ real_hostname = '',
+ by_hostname = 'mx1.freebsd.org',
+ },
+ },
{[[from out-9.smtp.github.com (out-9.smtp.github.com [192.30.254.192])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
@@ -91,7 +104,7 @@ context("Received headers parser", function()
real_ip = '65.19.167.131',
by_hostname = 'mail01.someotherdomain.org',
}
- }
+ },
}
local task = ffi.C.rspamd_task_new(nil, nil)
@@ -120,7 +133,7 @@ context("Received headers parser", function()
end
elseif k == 'from_ip' then
if #v > 0 then
- local got_string = tostring(rspamd_ip.from_string(ffi_string(hdr.from_ip)))
+ local got_string = tostring((rspamd_ip.from_string(ffi_string(hdr.from_ip) or '')) or '')
local expected_string = tostring(rspamd_ip.from_string(v))
assert_equal(expected_string, got_string,
string.format('%s: from_ip: %s, expected: %s',
@@ -132,7 +145,7 @@ context("Received headers parser", function()
end
elseif k == 'real_ip' then
if #v > 0 then
- local got_string = tostring(rspamd_ip.from_string(ffi_string(hdr.from_ip)))
+ local got_string = tostring((rspamd_ip.from_string(ffi_string(hdr.from_ip) or '')) or '')
local expected_string = tostring(rspamd_ip.from_string(v))
assert_equal(expected_string, got_string,
string.format('%s: real_ip: %s, expected: %s',