Hello glpi-dev team!
I have found bug in 0.72.4.
After applying my patch for decoding email, previous decoding mechanism also
recode some emails.
First decoding occur in mailgate.class.php in function get_part at
if (count($structure->parameters)>0){
foreach ($structure->parameters as
$param){
if
((strtoupper($param->attribute)=='CHARSET') &&
function_exists('mb_convert_encoding') && strtoupper($param->value) !=
'UTF-8'){
$text = mb_convert_encoding($text,
'utf-8',$param->value); // <<<<<first decoding
}
}
}
and second in same file in function buildTicket at
$body=$this->getBody($i);
// Do it before using charset variable
$head['subject']=$this->decodeMimeString($head['subject']);
if
(!empty($this->charset)&&function_exists('mb_convert_encoding')){
$body=mb_convert_encoding($body,
'utf-8',$this->charset); //<<<<<<<second recoding
}
because $this->charset filled from headers.
in attach patch for glpi 0.72.4 it add boolean variable "body_converted" to
check decoding state.
and second attached file, it is email with problem present.
Return-path: <[email protected]>
Received: from LocalHost by mail.somedomain.by
(MDaemon PRO v9.6.1)
with ESMTP id md50000692591.msg
for <[email protected]>; Wed, 28 Apr 2010 13:44:31 +0300
Authentication-Results: mail.somedomain.by
[email protected]; auth=pass ([email protected])
Authentication-Results: mail.somedomain.by
smtp.helo=LocalHost; ip-match=fail
From: "glpi" <[email protected]>
To: <[email protected]>
Subject: =?koi8-r?B?wdXUzNXLwTc=?=
Date: Wed, 28 Apr 2010 14:41:19 +0400
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0017_01CAE6E0.DDC3A610"
X-Mailer: Microsoft Office Outlook, Build 11.0.5510
Thread-Index: Acrmv1YBpXqt/5YbRk+7QVpPTaEd4w==
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Authenticated-Sender: [email protected]
X-Spam-Processed: mail.somedomain.by, Wed, 28 Apr 2010 13:44:31 +0300
(not processed: message from valid local sender)
X-Lookup-Warning: EHLO lookup on LocalHost does not match 1.2.3.4
X-Rcpt-To: [email protected]
X-MDRcpt-To: [email protected]
X-Return-Path: [email protected]
X-Envelope-From: [email protected]
X-MDaemon-Deliver-To: [email protected]
This is a multi-part message in MIME format.
------=_NextPart_000_0017_01CAE6E0.DDC3A610
Content-Type: text/plain;
charset="koi8-r"
Content-Transfer-Encoding: base64
4dXUzNXLwTcNCg0K
------=_NextPart_000_0017_01CAE6E0.DDC3A610
Content-Type: text/html;
charset="koi8-r"
Content-Transfer-Encoding: quoted-printable
<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dkoi8-r">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Arial;
color:windowtext;}
@page Section1
{size:595.3pt 841.9pt;
margin:2.0cm 42.5pt 2.0cm 3.0cm;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=3DRU link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>=E1=D5=D4=CC=D5=CB=C17<o:p></o:p></span></font></p>
</div>
</body>
</html>
------=_NextPart_000_0017_01CAE6E0.DDC3A610--
--- ./mailgate.class.php.old 2010-03-02 11:06:00.000000000 +0300
+++ ./mailgate.class.php 2010-04-28 14:46:58.000000000 +0400
@@ -195,6 +195,8 @@
var $addtobody;
/// Number of ferchs emails
var $fetch_emails=0;
+ /// Body converted
+ var $body_converted=false;
/**
* Constructor
@@ -316,7 +318,7 @@
// Do it before using charset variable
$head['subject']=$this->decodeMimeString($head['subject']);
- if (!empty($this->charset)&&function_exists('mb_convert_encoding')){
+ if (!$this->body_converted&&!empty($this->charset)&&function_exists('mb_convert_encoding')){
$body=mb_convert_encoding($body, 'utf-8',$this->charset);
}
if (!seems_utf8($body)){
@@ -589,6 +591,7 @@
foreach ($structure->parameters as $param){
if ((strtoupper($param->attribute)=='CHARSET') && function_exists('mb_convert_encoding') && strtoupper($param->value) != 'UTF-8'){
$text = mb_convert_encoding($text, 'utf-8',$param->value);
+ $this->body_converted=true;
}
}
}
_______________________________________________
Glpi-dev mailing list
[email protected]
https://mail.gna.org/listinfo/glpi-dev