summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libserver/dkim.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index 2031f39fd..db916e837 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -1907,6 +1907,11 @@ rspamd_dkim_check (rspamd_dkim_context_t *ctx,
body_end = task->msg.begin + task->msg.len;
headers_end = task->msg.begin + task->raw_headers_content.len;
+ while ((*headers_end == '\r' || *headers_end == '\n') &&
+ headers_end < body_end) {
+ headers_end ++;
+ }
+
/* Start canonization of body part */
if (!rspamd_dkim_canonize_body (&ctx->common, headers_end, body_end)) {
return DKIM_RECORD_ERROR;
@@ -2186,11 +2191,14 @@ rspamd_dkim_sign (struct rspamd_task *task,
/* Now canonize headers */
for (i = 0; i < ctx->common.hlist->len; i++) {
dh = g_ptr_array_index (ctx->common.hlist, i);
- rspamd_dkim_canonize_header (&ctx->common, task, dh->name, dh->count,
- NULL, NULL);
- for (j = 0; j < dh->count; j++) {
- rspamd_printf_gstring (hdr, "%s:", dh->name);
+ if (g_hash_table_lookup (task->raw_headers, dh->name)) {
+ rspamd_dkim_canonize_header (&ctx->common, task, dh->name, dh->count,
+ NULL, NULL);
+
+ for (j = 0; j < dh->count; j++) {
+ rspamd_printf_gstring (hdr, "%s:", dh->name);
+ }
}
}