[imp] fold long headers

Jan Schneider jan@horde.org
Mon, 8 Jul 2002 11:45:00 +0200


Zitat von Wenzhuo Zhang <wenzhuo@zhmail.com>:

> 
> Hi,
> 
> According to rfc #2047, 
> 
>    While there is no limit to the length of a multiple-line header
>    field, each line of a header field that contains one or more
>    'encoded-word's is limited to 76 characters.
> 
> So I guess the first recursive invocation of MIME::encode() in MIME.php
> should be called with $outer=false.
> 
> --- horde/lib/MIME.php.dist	Sun Apr  7 00:19:19 2002
> +++ horde/lib/MIME.php	Sun Jul  7 23:22:41 2002
> @@ -66,7 +66,7 @@
>      {
>          if (MIME::is8bit($text)) {
>              if (((strlen($text) * 3) + strlen($charset) + 7) > 76) {
> -                $text = MIME::encode(substr($text, 0, (23 -
> strlen($charset))), $charset) . MIME::encode(substr($text, (23 -
> strlen($charset))), $charset, false);
> +                $text = MIME::encode(substr($text, 0, (23 -
> strlen($charset))), $charset, false) . MIME::encode(substr($text, (23 -
> strlen($charset))), $charset, false);
>              } else {
>                  $text = "=?$charset?B?" .
> strtr(trim(base64_encode($text)), ' ', '_') . "?=\n\t";
>              }

Hm, I'm not sure about this. Michael, I guess you know better what to do here.
 
> Another problem with MIME:encode() is that header fields are split
> into segments of 23 characters, which would cause a multi-byte
> character to be split across 'encoded words'. Well, it's not a simple
> fix 'cause it involves so many character sets which have multi-byte
> characters. iconv is the way to go, IMHO.

I guess the easiest way to handle such cases is to enable mbstring
overloading for your site or the Horde directory. See
http://www.php.net/manual/en/ref.mbstring.php for how to enable string
function overloading. The  mbstring.func_overload value should be set to at
least 2.

Jan.

--
http://www.horde.org - The Horde Project
http://www.ammma.de - discover your knowledge
http://www.tip4all.de - Deine private Tippgemeinschaft