[Spambayes] Bug

Richie Hindle richie at entrian.com
Tue Aug 12 00:19:59 EDT 2003


Hi John,

> Got this from SpamBayes, just downloaded and installed the latest from 
> the site today and installed for the first time.
> 
> X-Spambayes-Exception: exceptions.UnicodeDecodeError('ascii' codec can't
>          decode byte 0xf1 in position 62: ordinal not in range(128))
>          in append() at C:\Python23\lib\email\Header.py line 272: ustr
>          = unicode(s, incodec, errors)

This is fixed in CVS.  You can apply the most important part of the fix by
changing this:

                    enc = Header(value, header_name=name, continuation_ws='\t')
                    header = "%s: %s" % (name, str(enc))

to this:

                    header = "%s: %s" % (name, value)

around line 475 of pop3proxy.py.  That will solve the problem, but will
also mean that the X-Spambayes-Evidence header is not line-wrapped.  That
could potentially cause problems for your email client (though that's
unlikely).  If it does, you need to change this:

            self[options['Headers','evidence_header_name']] = "; ".join(evd)

to this:

            # Line-wrap this header, because it can get very long.  We don't
            # use email.Header.Header because that can explode with unencoded
            # non-ASCII characters.  We can't use textwrap because that's 2.3.
            wrappedEvd = []
            headerName = options['Headers','evidence_header_name']
            lineLength = len(headerName) + len(': ')
            for component, index in zip(evd, range(len(evd))):
                wrappedEvd.append(component)
                lineLength += len(component)
                if index < len(evd)-1:
                    if lineLength + len('; ') + len(evd[index+1]) < 78:
                        wrappedEvd.append('; ')
                    else:
                        wrappedEvd.append(';\n\t')
                        lineLength = 8
            self[headerName] = "".join(wrappedEvd)

at around line 292 of spambayes/message.py.

-- 
Richie Hindle
richie at entrian.com




More information about the Spambayes mailing list