[imp] fold long headers

Wenzhuo Zhang wenzhuo@zhmail.com
Sun, 7 Jul 2002 23:59:53 +0800


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";
             }

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.

-- 
Wenzhuo
  GnuPG Key ID 0xBA586A68
  Key fingerprint = 89C7 C6DE D956 F978 3F12  A8AF 5847 F840 BA58 6A68