Fix a couple more 'string concat on array push' bugs like the
[squirrelmail.git] / class / mime / Rfc822Header.class.php
index e809797660a0b6fd7d386f6f3be659bce6c4bbeb..51141440a90fa6ee29f83a182b6ec97c2fa76fd8 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * Rfc822Header.class.php
  *
- * Copyright (c) 2003-2004 The SquirrelMail Project Team
+ * Copyright (c) 2003-2005 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This contains functions needed to handle mime messages.
@@ -186,7 +186,9 @@ class Rfc822Header {
                 $this->xmailer = $value;
                 break;
             case 'x-priority':
-                $this->priority = $value;
+            case 'importance':
+            case 'priority':
+                $this->priority = $this->parsePriority($value);
                 break;
             case 'list-post':
                 $value = $this->stripComments($value);
@@ -504,6 +506,31 @@ class Rfc822Header {
         }
     }
 
+    /**
+     * Normalise the different Priority headers into a uniform value,
+     * namely that of the X-Priority header (1, 3, 5). Supports:
+     * Prioirty, X-Priority, Importance.
+     * X-MS-Mail-Priority is not parsed because it always coincides
+     * with one of the other headers.
+     *
+     * NOTE: this is actually a duplicate from the function in
+     * functions/imap_messages. I'm not sure if it's ok here to call
+     * that function?
+     */
+    function parsePriority($value) {
+        $value = strtolower(array_shift(split('/\w/',trim($value))));
+        if ( is_numeric($value) ) {
+            return $value;
+        }
+        if ( $value == 'urgent' || $value == 'high' ) {
+            return 1;
+        } elseif ( $value == 'non-urgent' || $value == 'low' ) {
+            return 5;
+        }
+        // default is normal priority
+        return 3;
+    }
+
     function parseContentType($value) {
         $pos = strpos($value, ';');
         $props = '';