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]>
--===============0613161924==
Content-Type: multipart/alternative; 
	boundary="----=_Part_2038_13488079.1205524817615"

------=_Part_2038_13488079.1205524817615
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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=B4ve 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 th=
e
Content-Type header or if there=B4s 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=E7=E3o ao mercado  de A=E7oes

Content-Type: text/html;

        charset=3D"utf-8"



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

Subject:
=3D?UTF-8--utf?Q?Seu_pedido_(pensomail_antispam_-_confirme_mensagem_para_mb=
?=3D
[email protected].)_n=3DC3=3DA3o_foi_reconhecido!?=
=3D

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



 -- a really don=B4t know -1252 charset. think it does not exist.

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



Does that make sense ? There=B4s any way to fix it with those samples? Need
more samples?  I can=B4t program in python, otherwise I=B4d look into the c=
ode.
:(

------=_Part_2038_13488079.1205524817615
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<div>Hi,</div>
<div>&nbsp;</div>
<div>I have the UnicodeDecodeError in my tmda-cgi for some long time. Every=
time a user complains I delete the message manualy.&nbsp;&nbsp;After google=
ing for the problem I=B4ve got no solutions for it. Nobody could describe t=
he problem corretly and the development team could not solve it.</div>

<div>&nbsp;</div>
<div>After analizing many headers with the problem, I think I solved the pr=
oblem. TMDA-CGI exit with error when the Subject uses a different encoding =
than the Content-Type header&nbsp;or if there=B4s any problem with the &#39=
;charset&#39; field in Content-Type header.</div>

<div>&nbsp;</div>
<div>Exemples that crashes TMDA-CGI: </div>
<div>&nbsp;</div>
<div>-- this one says to use utf-8 but uses latin-1 in the subject.&nbsp;</=
div>
<div>
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><font size=3D"3"><font=
 face=3D"Calibri">Subject: Curso de Introdu=E7=E3o ao mercado<span style=3D=
"mso-spacerun: yes">&nbsp; </span>de A=E7oes</font></font></p>
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><span lang=3D"EN-US" s=
tyle=3D"mso-ansi-language: EN-US"><font size=3D"3"><font face=3D"Calibri">C=
ontent-Type: text/html;</font></font></span></p>
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><font size=3D"3"><font=
 face=3D"Calibri"><span lang=3D"EN-US" style=3D"mso-ansi-language: EN-US"><=
span style=3D"mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 </span></span>charset=3D&quot;utf-8&quot;</font></font></p>

<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><font size=3D"3"><font=
 face=3D"Calibri"></font></font>&nbsp;</p>
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><font size=3D"3"><font=
 face=3D"Calibri">-- this one uses utf, but the charset is strange</font></=
font></p></div>
<div>
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><span style=3D"FONT-SI=
ZE: 10.5pt; FONT-FAMILY: Consolas; mso-fareast-font-family: &#39;Times New =
Roman&#39;; mso-fareast-theme-font: minor-fareast; mso-fareast-language: PT=
-BR; mso-no-proof: yes">Subject: =3D?UTF-8--utf?Q?Seu_pedido_(pensomail_ant=
ispam_-_confirme_mensagem_para_mb?=3D<span style=3D"mso-spacerun: yes">&nbs=
p; </span>[email protected].)_n=3DC3=3DA3o_foi_rec=
onhecido!?=3D</span></p>

<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt">
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><span lang=3D"EN-US" s=
tyle=3D"FONT-SIZE: 10.5pt; FONT-FAMILY: Consolas; mso-fareast-font-family: =
&#39;Times New Roman&#39;; mso-fareast-theme-font: minor-fareast; mso-farea=
st-language: PT-BR; mso-no-proof: yes; mso-ansi-language: EN-US"></span></p=
>
<span lang=3D"EN-US" style=3D"FONT-SIZE: 10.5pt; FONT-FAMILY: Consolas; mso=
-fareast-font-family: &#39;Times New Roman&#39;; mso-fareast-theme-font: mi=
nor-fareast; mso-fareast-language: PT-BR; mso-no-proof: yes; mso-ansi-langu=
age: EN-US">Content-Type: text/plain; charset=3D&quot;UTF-8--utf&quot;</spa=
n>=20
<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><span lang=3D"EN-US" s=
tyle=3D"FONT-SIZE: 10.5pt; FONT-FAMILY: Consolas; mso-fareast-font-family: =
&#39;Times New Roman&#39;; mso-fareast-theme-font: minor-fareast; mso-farea=
st-language: PT-BR; mso-no-proof: yes; mso-ansi-language: EN-US">&nbsp;</sp=
an></p>

<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><span lang=3D"EN-US" s=
tyle=3D"FONT-SIZE: 10.5pt; FONT-FAMILY: Consolas; mso-fareast-font-family: =
&#39;Times New Roman&#39;; mso-fareast-theme-font: minor-fareast; mso-farea=
st-language: PT-BR; mso-no-proof: yes; mso-ansi-language: EN-US">&nbsp;-- a=
 really don=B4t know -1252 charset. think it does not exist.</span></p>

<p class=3D"MsoNormal" style=3D"MARGIN: 0cm 0cm 0pt"><span lang=3D"EN-US" s=
tyle=3D"FONT-SIZE: 10.5pt; FONT-FAMILY: Consolas; mso-fareast-font-family: =
&#39;Times New Roman&#39;; mso-fareast-theme-font: minor-fareast; mso-farea=
st-language: PT-BR; mso-no-proof: yes; mso-ansi-language: EN-US">Content-Ty=
pe: text/html; charset=3D&quot;-1252&quot;</span></p>

<p>&nbsp;</p>
<p>Does that make sense ? There=B4s any way to fix it with those samples? N=
eed more samples?&nbsp; I can=B4t program in python, otherwise I=B4d look i=
nto the code. :(</p>
<p>&nbsp;</p>
<p>&nbsp;</p></p></div>

------=_Part_2038_13488079.1205524817615--

--===============0613161924==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline