PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #9711

missing spaces in subject with german umlaut

Details

Submitted2006-12-29 16:27 UTC
Fromarno at shopnix dot de
Assignedcipri
StatusClosed
PackageMail_Mime
PHP Version4.4.4
OSLinux (Debian)
Roadmaps(Not assigned)

Comments

[2006-12-29 16:27 UTC] arno at shopnix dot de

Description:
------------
If there are two following words containing a german umlaut, the space between the two words is missing. I'm not really sure, that this is a bug in the implementation of PEAR, but the result is shown wrong in Thunderbird and in the web clients of Germanys largest freemail providers web.de and gmx.de.

A subject to test could be:
Ein Küßchen über dem Näschen für ein Häschen

Test script:
---------------
include('Mail.php');
include('Mail/mime.php');
$text = "Ein Küßchen über dem Näschen für ein Häschen\n";
$crlf = "\n";
$hdrs = array(
'From' => 'max@example.com',
'Subject' => 'Ein Küßchen über dem Näschen für ein Häschen'
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');
$mail->send('karl@example.com', $hdrs, $body);

Expected result:
----------------
Subject: Ein Küßchen über dem Näschen für ein Häschen

Actual result:
--------------
Subject: Ein Küßchenüber dem Näschenfür ein Häschen

[2007-01-24 11:32 UTC] chabrol at vfnm dot de

Hello!

It it's a bug. The function _encodeHeaders in Mail/mime.php violates RFC-1522 if there are successive words with special-chars (missing space between words) or a word with more than one special-char.
You can try to replace the function with my own version.

Best regards,
Daniel Chabrol

function _encodeHeaders($input)
{
foreach ($input as $hdr_name => $hdr_value) {
if (!preg_match('/[\x80-\xFF]/', $hdr_value)) {
continue;
}
$encoded = '=?' . $this->_build_params['head_charset'] . '?Q?';
for ($i=0; $i<strlen($hdr_value); $i++) {
$code = ord(substr($hdr_value, $i, 1));
if ($code == 61 || $code == 63 || $code == 32 || $code > 127) {
$encoded .= '=' . strtoupper(dechex($code));
} else {
$encoded .= chr($code);
}
}
$encoded .= '?=';
$input[$hdr_name] = $encoded;
}
return $input;
}