[Spambayes] Re: [Spambayes-checkins] spambayes/spambayes
message.py, 1.12, 1.13
T.A.Meyer at massey.ac.nz
Mon Apr 21 16:34:25 EDT 2003
> return re.sub(r'(?:\r\n|\n|\r(?!\n))', "\r\n", data)
> I don't think the negative lookahead assertion is necessary.
> By default, regular expressions are greedy (match the largest
> possible string), so
> return re.sub(r"\r\n|\n|\r", "\r\n", data)
> should work. Any time \r\n appears, it will be preferred
> over either \r or \n, so if the \r branch matches, that
> implies it wasn't followed by \n. If I've been laboring
> under a misconception for all these years, I'd be happy to be
I'm not sure if I commented this anywhere, but I lifted the regex
straight from smtplib, since it's doing the same thing as we want to do.
Yours sounds good (to me, who is a regex-beginner), so if it is right, I
guess I should submit a patch for smtplib as well :)
> Yours should work better than what's there right
> now, and I'm thinking about this one as well: '\r\n?|\n'
Again, this looks like it would work to me; surely it can't be this
simple, though, can it? ;)
> (and the issue of why it's there in the first place).
Well, this is because the imapfilter doesn't do this for us, as it
should. I suppose we should move this into the IMAPMessage class, since
messages over SMTP will be ok. Hopefully a later version of the imaplib
will fix this, but while we need to be compatible with Python 2.2, we'll
have to have it in there.
More information about the Spambayes