There was a problem when passing arrays to the decode header. From
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 6 Feb 2002 10:14:07 +0000 (10:14 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 6 Feb 2002 10:14:07 +0000 (10:14 +0000)
now, if an array is passed we run a conversion on that array to
transform it to a \n separated string.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2371 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mime.php

index 7ff842357e223f25839d7b43a6df25d15d0fb9b0..e9a6b4a970b51b862c19199fa97e43bfcfb091c2 100644 (file)
@@ -770,33 +770,40 @@ function decodeBody($body, $encoding) {
  * RFC1522 (MIME Part Two: Message Header Extensions for Non-ASCII Text).
  */
 function decodeHeader ($string, $utfencode=true) {
-  if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
+
+if ( is_array( $string ) ) {
+    $string = implode("\n", $string );
+}
+
+if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
             $string, $res)) {
-     if (ucfirst($res[2]) == 'B') {
+    if (ucfirst($res[2]) == 'B') {
         $replace = base64_decode($res[3]);
-     } else {
+    } else {
         $replace = str_replace('_', ' ', $res[3]);
-    // Convert lowercase Quoted Printable to uppercase for
-    // quoted_printable_decode to understand it.
-    while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))", $replace, $res)) {
-       $replace = str_replace($res[1], strtoupper($res[1]), $replace);
-    }
+        // Convert lowercase Quoted Printable to uppercase for
+        // quoted_printable_decode to understand it.
+        while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))",
+               $replace, $res)) {
+            $replace = str_replace($res[1], strtoupper($res[1]), $replace);
+        }
         $replace = quoted_printable_decode($replace);
-     }
-     /* Only encode into entities by default. Some places
+    }
+    /* Only encode into entities by default. Some places
         don't need the encoding, like the compose form. */
-     if ($utfencode){
-         $replace = charset_decode ($res[1], $replace);
-     }
+    if ($utfencode){
+        $replace = charset_decode ($res[1], $replace);
+    }
+
+    // Remove the name of the character set.
+    $string = eregi_replace ('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
+              $replace, $string);
 
-     // Remove the name of the character set.
-     $string = eregi_replace ('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=',
-         $replace, $string);
+    // In case there should be more encoding in the string: recurse
+    $string = decodeHeader($string);
+}
 
-     // In case there should be more encoding in the string: recurse
-     return (decodeHeader($string));
-  } else
-     return ($string);
+return ($string);
 }
 
 /*