[Mailman-Users] UnicodeDecodeError in Commands/cmd_subscribe.py

David Relson relson at osagesoftware.com
Mon Jan 24 01:49:21 CET 2005


On Mon, 24 Jan 2005 09:21:38 +0900
Tokio Kikuchi wrote:

> Hi,
> 
> David Relson wrote:
> 
> > Greetings,
> > 
> > I just noticed this Traceback (and several older ones just like it):
> > 
> > Jan 23 14:28:08 2005 (1640) Traceback (most recent call last):
> >   File "/usr/lib/mailman/Mailman/Queue/Runner.py", line 111, in _oneloop
> >     self._onefile(msg, msgdata)
> >   File "/usr/lib/mailman/Mailman/Queue/Runner.py", line 167, in _onefile
> >     keepqueued = self._dispose(mlist, msg, msgdata)
> >   File "/usr/lib/mailman/Mailman/Queue/CommandRunner.py", line 239, in _dispose
> >     res.do_command('join')
> >   File "/usr/lib/mailman/Mailman/Queue/CommandRunner.py", line 137, in do_command
> >     return handler.process(self, args)
> >   File "/usr/lib/mailman/Mailman/Commands/cmd_subscribe.py", line 87, in process
> >     h = make_header(decode_header(realname))
> >   File "/home/relson/tmp/RPM/mailman-buildroot/usr/lib/mailman/pythonlib/email/Header.py", line 144, in make_header
> >   File "/home/relson/tmp/RPM/mailman-buildroot/usr/lib/mailman/pythonlib/email/Header.py", line 272, in append
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xb3 in position 0: ordinal not in range(128)
> > 
> > Looking at the code, it looks like the fix should be (roughly) what's below.  Am I close???
> 
> This was fixed in CVS in a different way. This person should however fix 
> his MUA to send MIME compliant user address. Thank you for reporting.

Hi Tokio,

The sender is a spammer.  I very much doubt he'll either mend his ways or his software.

By the way, I'd much like to see a hook allowing mailman to call an
external spam filter when a message arrives from an unknown sender.  For
my lists, most messages from unknown senders are spam.  Rather than deal
with them manually, I'd like to have mailman call an external spam
filter and use the result to pass the message to the moderator or to
discard the message if it's spammish.

I've got something like the following in mind:

### for Handlers/Moderate.py

def do_spamcheck(msg):
    try:
        fp = os.popen(mm_cfg.SPAM_COMMAND, 'w')
        fp.write(msg)
        result = fp.close()

        # Spam   - None (0)
        # Ham    - 1
        # Unsure - 2

        if result == None:
            return 'Spam'
        else:
            result = result >> 8
            if result == 1:
                return 'Ham'
            if result == 2:
                return 'Unsure'
    except:
        return 'Unknown'


### in function process of Moderate.py

    #### Run spam filter; discard if spam ####
    if do_spamcheck(msg) == 'Spam':
        do_discard(mlist, msg)

Regards,

David





More information about the Mailman-Users mailing list