diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 32b0083a6df2c077defd19ac1560627b20ab877c..89b1f777666a3f9c2d7a7ce7e988f2e848b8696d 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -302,22 +302,36 @@ class Mail_Parse { return Mail_Parse::parsePriority($this->getHeader()); } - function parsePriority($header=null){ - - $priority=0; - if($header && ($begin=strpos($header,'X-Priority:'))!==false){ - $begin+=strlen('X-Priority:'); - $xpriority=preg_replace("/[^0-9]/", "",substr($header, $begin, strpos($header,"\n",$begin) - $begin)); - if(!is_numeric($xpriority)) - $priority=0; - elseif($xpriority>4) - $priority=1; - elseif($xpriority>=3) - $priority=2; - elseif($xpriority>0) - $priority=3; - } - return $priority; + static function parsePriority($header=null){ + + if (! $header) + return 0; + // Test for normal "X-Priority: INT" style header & stringy version. + // Allows for Importance possibility. + $matching_char = ''; + if (preg_match ( '/priority: (\d|\w)/i', $header, $matching_char ) + || preg_match ( '/importance: (\d|\w)/i', $header, $matching_char )) { + switch ($matching_char[1]) { + case 'h' : + case 'H' :// high + case 'u': + case 'U': //Urgent + case 6 : + case 5 : + return 1; + case 'n' : // normal + case 'N' : + case 4 : + case 3 : + return 2; + case 'l' : // low + case 'L' : + case 2 : + case 1 : + return 3; + } + } + return 0; } function parseAddressList($address){