UnicodeDecodeError - problem identified. How to solve?

"Thiago Lima" <[email protected]> Fri, 14 Mar 2008 17:00:17 -0300
Newsgroups gmane.mail.spam.tmda.devel,gmane.mail.spam.tmda.user
Message-ID <[email protected]>
Hi,

I have the UnicodeDecodeError in my tmda-cgi for some long time. Everytime a
user complains I delete the message manualy.  After googleing for the
problem I´ve got no solutions for it. Nobody could describe the problem
corretly and the development team could not solve it.

After analizing many headers with the problem, I think I solved the problem.
TMDA-CGI exit with error when the Subject uses a different encoding than the
Content-Type header or if there´s any problem with the 'charset' field in
Content-Type header.

Exemples that crashes TMDA-CGI:

-- this one says to use utf-8 but uses latin-1 in the subject.

Subject: Curso de Introdução ao mercado  de Açoes

Content-Type: text/html;

        charset="utf-8"



-- this one uses utf, but the charset is strange

Subject:
=?UTF-8--utf?Q?Seu_pedido_(pensomail_antispam_-_confirme_mensagem_para_mb?=
[email protected].)_n=C3=A3o_foi_reconhecido!?=

Content-Type: text/plain; charset="UTF-8--utf"



 -- a really don´t know -1252 charset. think it does not exist.

Content-Type: text/html; charset="-1252"



Does that make sense ? There´s any way to fix it with those samples? Need
more samples?  I can´t program in python, otherwise I´d look into the code.
:(