Joe Pallas wrote on 10/30/12 10:09:
>
> On Oct 29, 2012, at 8:07 PM, Bill Shannon wrote:
>
>> One of the reasons I asked here is because of the interaction between
>> the syntax of these header fields and what an IMAP server should do
>> when parsing the header and returning the parsed value.
>
> I would say that you are probably right that servers are not actually obeying the spec but it?s hard to see that it matters. If I ask an IMAP server to fetch ?BODY[HEADER.FIELDS (Subject)]? I don?t get back a parsed value, I get back the entire subject line, including any white space between the colon and the first non-WS character.
>
> The two occasions I can think of where skipping white space in an unstructured header might matter are:
> 1) ENVELOPE, which contains the subject string, and
> 2) SEARCH of the subject string
>
> It appears that many servers will elide leading spaces from the subject in the returned ENVELOPE structure. It also appears that some servers will ignore leading spaces in search strings. At least one server does the former but not the latter.
>
> I can?t imagine relying on the server?s parsing for something like a digital signature. Unless the server is actually modifying the message headers returned by a non-ENVELOPE fetch, though, I don?t think this should be a concern.
Yes, you can always ask for the raw header line and parse it yourself if the
difference matters to you. I think the mistake was writing a digital
signature spec that depended on the difference, rather than canonicalizing
the data first. We could argue whether such canonicalization should include
just stripping leading and trailing whitespace, or should also include
converting any sequences of whitespace to a single space character.
It would also be nice if the IMAP spec indicated that these fields are
canonicalized in some (perhaps undefined) way, although without agreeing
on the canonicalization algorithm you still couldn't rely on the data when
computing a digital signature.