mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
cmdeploy/opendkim/final.lua: Readability refactor of header pruning
Refactor DKIM-Header-Pruning into a "if valid-else" construct with a single "return nil" at the end
This commit is contained in:
@@ -28,7 +28,13 @@ for i = 1, nsigs do
|
||||
end
|
||||
end
|
||||
|
||||
if not valid then
|
||||
if valid then
|
||||
-- Strip all DKIM-Signature headers after successful validation
|
||||
-- Delete in reverse order to avoid index shifting.
|
||||
for i = nsigs, 1, -1 do
|
||||
odkim.del_header(ctx, "DKIM-Signature", i)
|
||||
end
|
||||
else
|
||||
odkim.set_reply(ctx, "554", "5.7.1", "No valid DKIM signature found")
|
||||
-- Delete in reverse order to avoid index shifting.
|
||||
for i = nsigs, 1, -1 do
|
||||
@@ -37,13 +43,6 @@ if not valid then
|
||||
else
|
||||
odkim.set_reply(ctx, "554", "5.7.1", error_msg)
|
||||
odkim.set_result(ctx, SMFIS_REJECT)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Valid signature found. Strip all DKIM-Signature headers
|
||||
-- Delete in reverse order to avoid index shifting.
|
||||
for i = nsigs, 1, -1 do
|
||||
odkim.del_header(ctx, "DKIM-Signature", i)
|
||||
end
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user