aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-24 23:56:56 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-06-24 23:56:56 +0100
commit3c5de0377a4edaa6ad65043350688df189020de6 (patch)
tree4d225209ff3ea71d73544b8e19f0169552b59584 /src
parent0996980c72da7ad609b8c0dcfaa82feffd981c3c (diff)
downloadrspamd-3c5de0377a4edaa6ad65043350688df189020de6.tar.gz
rspamd-3c5de0377a4edaa6ad65043350688df189020de6.zip
[Fix] Use `\n` to fold headers for milter
Diffstat (limited to 'src')
-rw-r--r--src/libserver/protocol.c31
-rw-r--r--src/libserver/protocol_internal.h1
-rw-r--r--src/libserver/task.h1
3 files changed, 31 insertions, 2 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 6992307a2..6ccb83229 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -442,6 +442,10 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
mta_name, NULL);
debug_task ("read MTA-Name header, value: %s", mta_name);
}
+ IF_HEADER (MILTER_HEADER) {
+ task->flags |= RSPAMD_TASK_FLAG_MILTER;
+ debug_task ("read Milter header, value: %V", hv);
+ }
break;
default:
debug_task ("unknown header: %V", hn);
@@ -1172,8 +1176,31 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
RSPAMD_MEMPOOL_DKIM_SIGNATURE);
if (dkim_sig) {
- GString *folded_header = rspamd_header_value_fold ("DKIM-Signature",
- dkim_sig->str, 80, task->nlines_type);
+ GString *folded_header;
+
+ if (task->flags & RSPAMD_TASK_FLAG_MILTER) {
+ folded_header = rspamd_header_value_fold ("DKIM-Signature",
+ dkim_sig->str, 80, RSPAMD_TASK_NEWLINES_LF);
+ }
+ else {
+ folded_header = rspamd_header_value_fold ("DKIM-Signature",
+ dkim_sig->str, 80, task->nlines_type);
+ }
+ /*
+ * According to milter docs, we need to be extra careful
+ * when folding headers:
+ * Neither the name nor the value of the header is checked for standards
+ * compliance. However, each line of the header must be under 2048
+ * characters and should be under 998 characters.
+ * If longer headers are needed, make them multi-line.
+ * To make a multi-line header, insert a line feed (ASCII 0x0a, or \n
+ * in C) followed by at least one whitespace character such as a
+ * space (ASCII 0x20) or tab (ASCII 0x09, or \t in C).
+ * The line feed should NOT be preceded by a carriage return (ASCII 0x0d);
+ * the MTA will add this automatically.
+ * It is the filter writer's responsibility to ensure that no s
+ * tandards are violated.
+ */
ucl_object_insert_key (top,
ucl_object_fromstring_common (folded_header->str,
folded_header->len, UCL_STRING_RAW),
diff --git a/src/libserver/protocol_internal.h b/src/libserver/protocol_internal.h
index 48c1c23f1..41ba13d86 100644
--- a/src/libserver/protocol_internal.h
+++ b/src/libserver/protocol_internal.h
@@ -79,5 +79,6 @@
#define TLS_CIPHER_HEADER "TLS-Cipher"
#define TLS_VERSION_HEADER "TLS-Version"
#define MTA_NAME_HEADER "MTA-Name"
+#define MILTER_HEADER "Milter"
#endif //RSPAMD_PROTOCOL_INTERNAL_H
diff --git a/src/libserver/task.h b/src/libserver/task.h
index cc1cc492a..16e40aad1 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -107,6 +107,7 @@ enum rspamd_task_stage {
#define RSPAMD_TASK_FLAG_PROFILE (1 << 25)
#define RSPAMD_TASK_FLAG_GREYLISTED (1 << 26)
#define RSPAMD_TASK_FLAG_OWN_POOL (1 << 27)
+#define RSPAMD_TASK_FLAG_MILTER (1 << 28)
#define RSPAMD_TASK_IS_SKIPPED(task) (((task)->flags & RSPAMD_TASK_FLAG_SKIP))
#define RSPAMD_TASK_IS_JSON(task) (((task)->flags & RSPAMD_TASK_FLAG_JSON))