Transfert d'un mail d'un russe qui est passé sur IRC, il a fait un patch à cause d'un problème d'encodage de sujet de mail. Il utilise thunderbird.
> So, short description: > subject looks ugly when encoded in utf-8. At least in thunderbird. > This is because of incorrect mime encoding. > Here is wrong header: > > Subject: > =?utf-8?B?W0dMUEkgIzAwMDAwNjRdINCX0LDRj9Cy0LrQsCDQt9Cw0LrRgNGL0YLQsCAy?= > =?utf-8?B?MDA4LTEwLTE1IDE1OjI3OjA4IC0g0J/RgNC10LTQvtGB0YLQsNCy0LvQtdC9?= > =?utf-8?B?0LjQtSDQtNC+0YHRgtGD0L/QsCDQuiDRgNC10YHRg9GA0YHQsNC8IEIyQiDR?= > =?utf-8?B?h9C10YDQtdC3IEludGVybmV0?= > > > And here is correct header: > > Subject: > =?UTF-8?B?W0dMUEkgIzAwMDAwNjRdINCX0LDRj9Cy0LrQsCDQt9Cw0LrRgNGL0YLQsCAyMDA4LTEwLTE1IDE1OjQ0?= > =?UTF-8?B?OjAzIC0g0J/RgNC10LTQvtGB0YLQsNCy0LvQtdC90LjQtSDQtNC+0YHRgtGD0L/QsCDQuiDRgNC10YHRg9GA0YHQsNC8IEIyQiDRh9C10YA=?= > =?UTF-8?B?0LXQtyBJbnRlcm5ldA==?= > > Text is same. So, diff is against version 0.70.2 but can be applied > with small changes to latest version. > > Thanks. >
--- class.phpmailer.php.orig 2008-01-28 14:50:42.000000000 +0300 +++ class.phpmailer.php 2008-06-23 17:40:24.000000000 +0400 @@ -1129,6 +1129,33 @@ return $encoded; } + + + + + + function MimeHeaderEncode($string, $split = true) { + if (preg_match('/[^\x20-\x7E]/', $string)) { + if (!$split) { + return ' =?UTF-8?B?'.base64_encode($string).'?='; + } + $chunk_size = 47; // floor((75 - strlen('=?UTF-8?B??=')) * 0.75); + $len = strlen($string); + $output = ''; + while ($len > 0) { + $chunk = mb_substr($string, 0, $chunk_size, 'utf-8'); + $output .= ' =?UTF-8?B?'.base64_encode($chunk)."?=\n"; + $c = strlen($chunk); + $string = substr($string, $c); + $len -= $c; + } + return trim($output); + } + return $string; + } + + + /** * Encode a header string to best of Q, B, quoted or none. * @access private @@ -1165,10 +1192,12 @@ $maxlen = 75 - 7 - strlen($this->CharSet); // Try to select the encoding which should produce the shortest output if (strlen($str)/3 < $x) { - $encoding = 'B'; - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); +// $encoding = 'B'; +// $encoded = base64_encode($str); +// $maxlen -= $maxlen % 4; +// $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + $encoded = $this->MimeHeaderEncode($str); + return $encoded; } else { $encoding = 'Q'; $encoded = $this->EncodeQ($str, $position);
--- mailing.class.php.orig 2008-01-28 14:50:42.000000000 +0300 +++ mailing.class.php 2008-06-23 14:49:57.000000000 +0400 @@ -413,7 +413,9 @@ } if (strlen($this->job->fields['name'])>150){ - $subject.=" - ".utf8_substr($this->job->fields['name'],0,150)." (...)"; + $subject.=" - ".$this->job->fields['name']; +// system('echo \"$subject >> /tmp/test.txt\"'); +// $subject.=" - ".utf8_substr($this->job->fields['name'],0,150)." (...)"; }else{ $subject.=" - ".$this->job->fields['name']; }
<<attachment: glpi-subject.jpg>>
_______________________________________________ Glpi-dev mailing list Glpi-dev@gna.org https://mail.gna.org/listinfo/glpi-dev