ID:               44570
 User updated by:  tokul at users dot sourceforge dot net
 Reported By:      tokul at users dot sourceforge dot net
 Status:           Open
 Bug Type:         mbstring related
 Operating System: Linux Debian Etch
 PHP Version:      5.2CVS-2008-03-30 (snap)
 New Comment:

If mbstring.internal_encoding is set, code does not need
mb_convert_encoding() call.


Previous Comments:
------------------------------------------------------------------------

[2008-03-30 12:28:18] tokul at users dot sourceforge dot net

Description:
------------
mb_encode_mimeheader incorrectly folds iso-2022 texts. rfc 2047 chapter
3 second paragraph says that folded string must be reverted to ASCII.
Code just splits ISO-2022 string without adding appropriate escapes.

Code works as expected only when mbstring.internal_encoding is set to
correct value. This dependency of mb_encode_mimeheader() is not
documented and catches all users that are not used to
mb_encode_mimeheader() quirks.

Reproduce code:
---------------
/** See
http://etext.lib.virginia.edu/japanese/hyakunin/frames/hyakuframes.html
*/
$string = "\xe7\xa7\x8b\xe3\x81\xae\xe7\x94\xb0\xe3\x81\xae\x20"
 ."\xe3\x81\x8b\xe3\x82\x8a\xe3\x81\xbb\xe3\x81\xae\xe5\xba\xb5"
 ."\xe3\x81\xae\x20\xe8\x8b\xab\xe3\x82\x92\xe3\x81\x82"
 ."\xe3\x82\x89\xe3\x81\xbf\x20\x20\xe3\x82\x8f\xe3\x81\x8c"
 ."\xe8\xa1\xa3\xe6\x89\x8b\xe3\x81\xaf\x20\xe9\x9c\xb2"
 ."\xe3\x81\xab\xe3\x81\xac\xe3\x82\x8c\xe3\x81\xa4\xe3\x81\xa4";

$string_iso2022 = mb_convert_encoding($string,'iso-2022-jp','utf-8');
echo mb_encode_mimeheader($string_iso2022,'iso-2022-jp','b');

Expected result:
----------------
=?ISO-2022-JP?B?GyRCPSkkTkVEJE4bKEIgGyRCJCskaiRbJE4wQyROGyhCIBskQkZRGyhC?=
=?ISO-2022-JP?B?GyRCJHIkIiRpJF8bKEIgIBskQiRvJCwwYTxqJE8bKEIgGyRCTyobKEI=?=
=?ISO-2022-JP?B?GyRCJEskTCRsJEQkRBsoQg==?=

Actual result:
--------------
=?ISO-2022-JP?B?GyRCPSkkTkVEJE4bKEIgGyRCJCskaiRbJE4wQyROGyhCIBskQkZRJHIk?=

=?ISO-2022-JP?B?IiRpJF8bKEIgIBskQiRvJCwwYTxqJE8bKEIgGyRCTyokSyRMJGwkRCRE?=
 =?ISO-2022-JP?B?GyhC?=


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44570&edit=1

Reply via email to