Folding Whitespace incompatible with the libmilter spec
Claus Assman at Sendmail points me to the libmilter specification for folding lines in headers transmitted to Sendmail. It seems to be at variance with RFC6376 Section 2.8 Whitespace.
The Libmilter specification, not an RFC, is the best example of a "samizdat" document I have yet seen. However since it is the operationally ruling protocol, perhaps DKIM folding whitespace should be in alignment with it?
Stephen Nightingale.
From Claus Assman at Sendmail:
Do you mean the milter uses \r\n?
The libmilter docs states:
* 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 standards
are violated.
My answer:
The folding algorithm in dkim.py is inserting "CRLF<sp>", thus.
This is based on the specification of folding whitespace in RFC6376,
Section 2.8, Page 15.
def fold(header):
"""Fold a header line into multiple crlf-separated lines at column 72.
"""
i = header.rfind(b"\r\n ")
if i == -1:
pre = b""
else:
i += 3
pre = header[:i]
header = header[i:]
while len(header) > 72:
i = header[
if i == -1:
j = 72
else:
j = i + 1
pre += header[:j] + b"\r\n "
header = header[j:]
return pre + header
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- dkimpy Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Stephen Nightingale for more information if necessary.