Added rfc2184 support in order to handle:
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 28 Jun 2003 20:17:17 +0000 (20:17 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 28 Jun 2003 20:17:17 +0000 (20:17 +0000)
Multilined parameters
Parameters with charset and language information.

Only problem:
I don't have a single message with rfc2184 headers so I couldn't test it.
Probably it works okay because the RFC wasn't that complicated.

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

class/mime/Rfc822Header.class.php

index d4d36604c1d1e76795314fb38af50bd6d2dfc87e..bcacda49280071f33b944e738d25e01b2dbd4734 100644 (file)
@@ -502,6 +502,38 @@ class Rfc822Header {
         }
         $this->content_type = $content_type;
     }
+    
+    /* RFC2184 */
+    function processParameters($aParameters) { 
+        $aResults = array();
+       $aCharset = array();
+       // handle multiline parameters
+        foreach($aParameters as $key => $value) {
+           if ($iPos = strpos($key,'*')) {
+               $sKey = substr($key,0,$iPos);
+               if (!isset($aResults[$sKey])) {
+                   $aResults[$sKey] = $value;
+                   if (substr($key,-1) == '*') { // parameter contains language/charset info
+                       $aCharset[] = $sKey;
+                   }
+               } else {
+                   $aResults[$sKey] .= $value;
+               }
+           }
+        }
+       foreach ($aCharset as $key) {
+           $value = $aResults[$key];
+           // extract the charset & language
+           $charset = substr($value,0,strpos($value,"'"));
+           $value = substr($value,strlen($charset)+1);
+           $language = substr($value,0,strpos($value,"'"));
+           $value = substr($value,strlen($charset)+1);
+           // FIX ME What's the status of charset decode with language information ????
+           $value = charset_decode($charset,$value);
+           $aResults[$key] = $value;
+       }
+       return $aResults;    
+    }
 
     function parseProperties($value) {
         $propArray = explode(';', $value);
@@ -518,7 +550,7 @@ class Rfc822Header {
                 $propResultArray[$key] = $val;
             }
         }
-        return $propResultArray;
+        return $this->processParameters($propResultArray);
     }
 
     function parseDisposition($value) {