This Space for Rent

New Code! (part 2)

Postoffice is joining the fun of the new code release festival by being shoved up to version 1.4.10, which does not have the new configuration code from discount in it (yet,) but which does have a minor code change:

When I wrote postoffice in the first place, I made up a fairly elaborate state machine to process CRLF.CRLF and LF.LF (for network and terminal traffic, respectively) and collapse down CRLF network line terminators to LF Unix line terminators. With well-behaved clients, this seemed to work very well, but there seems to be a largish body of mailers out there that appear to add additional CR’s to their mail bodies. And postoffice didn’t deal at all with that input, and would transpose the CR and the character immediately preceding it.

This made for some interesting results when the offending mail contained a url, which ended up having the last character clipped off and put on the next line.

I finally snapped and tried to correct this defect this last week. At first, I thought that I’d just completely miscoded the state machine, so I discarded it and put in a far simpler bit of code that does the same thing, but I was still getting naked CRs from these mailers. And, since it was no longer transposing the CR and the last character, some mail readers (like Apple’s Mail.app) decided that this meant that the whole mail message was lots of additional headers.

*sigh*

After spending some time trying to outguess these mailers, I finally gave up and redid the data() function so that it would silently discard all CRs it found in the input stream. Yes, it’s not very RFC-compliant, but it ends up with a larger body of mail that shows up at pell and is actually readable. So that’s as good a reason as any for some New Code!, don’t you think? I’m sure there’s some pathological case out there like someone doing an accounts-receivable system in whitespace who also uses postoffice, but sends plaintext copies of their code around for review. (This would be the imaginary language whitespace++, which uses CR as a magic “I am a class” marker)) where this will fail horribly, but, please, if you’re it, give me a couple of days before reporting the defect.)