From: carsten_sttgt at gmx dot de
Operating system: Windows_NT
PHP version: 5.3CVS-2009-05-09 (snap)
PHP Bug Type: IMAP related
Bug description: wrong behaviour and crash with imap_mail_compose()
Description:
------------
Hello,
from my understanding, and if I read RFC2045-sec6.2, imap_mail_compose()
is working in a wrong way. From RFC2045:
- With "binary", "8bit" and "7bit" no transforming is done.
- With "quoted-printable" and "base64", the data is transformed
to 7bit, according to the selected encoding type.
The behavior from imap_mail_compose():
- with ENC7BIT no Content-Transfer-Encoding header is set
(ok, that's the same. maybe correct)
- with ENC8BIT, the Content-Transfer-Encoding changes to
"quoted-printable" and the data is transfomed (wrong)
- with ENCBINARY, the Content-Transfer-Encoding changes to
"base64" and the data is transfomed (wrong)
- with ENCBASE64, the Content-Transfer-Encoding is "base64"
and the data is transfomed (correct)
- with ENCQUOTEDPRINTABLE, the Content-Transfer-Encoding is
"quoted-printable" and the data is transfomed (correct)
- ENCOTHER is imho not really useful (especially if I can't
set the name (foo) in x-foo).
Then I've tried to set the value for the Content-Transfer-Encoding header
on my own:
- with "binary", no Content-Transfer-Encoding header is set
- with "8bit" (or "7bit"), I have a segmentation fault (PHP crashes).
Regards,
Carsten
Reproduce code:
---------------
<?php
$data8bit = 'a german umlaut ä.';
$data7bit = 'just a text in us-ascii.';
$body = array();
$i = 0;
$body[++$i] = array(
'type' => TYPEMULTIPART,
'subtype' => 'mixed'
);
$body[++$i] = array(
'type' => TYPETEXT,
'charset' => 'us-ascii',
'encoding' => ENC7BIT,
'contents.data' => $data7bit
);
$body[++$i] = array(
'type' => TYPETEXT,
'charset' => 'iso-8859-1',
'encoding' => ENC8BIT,
'contents.data' => $data8bit
);
$body[++$i] = array(
'type' => TYPETEXT,
'charset' => 'iso-8859-1',
'encoding' => ENCBINARY,
'contents.data' => $data8bit
);
$body[++$i] = array(
'type' => TYPETEXT,
'charset' => 'iso-8859-1',
'encoding' => ENCBASE64,
'contents.data' => $data8bit
);
$body[++$i] = array(
'type' => TYPETEXT,
'charset' => 'iso-8859-1',
'encoding' => ENCQUOTEDPRINTABLE ,
'contents.data' => $data8bit
);
$body[++$i] = array(
'type' => TYPETEXT,
'charset' => 'iso-8859-1',
'encoding' => 'binary',
'contents.data' => $data8bit
);
//$body[++$i] = array(
// 'type' => TYPETEXT,
// 'charset' => 'iso-8859-1',
// 'encoding' => '8bit' ,
// 'contents.data' => $data8bit
//);
echo imap_mail_compose(array(), $body);
?>
Expected result:
----------------
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="62-22384-1241869364=:9856"
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=us-ascii
Content-Transfer-Encoding: 7BIT
just a text in us-ascii.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: 8BIT
a german umlaut ä.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: BINARY
a german umlaut ä.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: BASE64
YSBnZXJtYW4gdW1sYXV0IOQu
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
a german umlaut =E4.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: binary
a german umlaut ä.
--62-22384-1241869364=:9856--
Actual result:
--------------
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="62-22384-1241869364=:9856"
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=us-ascii
just a text in us-ascii.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
a german umlaut =E4.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: BASE64
YSBnZXJtYW4gdW1sYXV0IOQu
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: BASE64
a german umlaut ä.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
a german umlaut ä.
--62-22384-1241869364=:9856
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
a german umlaut ä.
--62-22384-1241869364=:9856--
--
Edit bug report at http://bugs.php.net/?id=48201&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48201&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48201&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48201&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48201&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48201&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48201&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48201&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48201&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48201&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48201&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48201&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48201&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48201&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48201&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48201&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48201&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48201&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48201&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48201&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48201&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48201&r=mysqlcfg