Better support for malformed/absent dates and headerlines ending in only "\n".
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 28 Feb 2004 15:13:17 +0000 (15:13 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 28 Feb 2004 15:13:17 +0000 (15:13 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6695 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
class/mime/Rfc822Header.class.php
functions/date.php
functions/imap_messages.php

index 70734e4b0c3acf4f16031c6cd382526a82188ad3..fec652b849579a664eaaeb5365eb1a2a743b04a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@ Version 1.5.1 -- CVS
   - sqimap_create_stream() was not obeying passed params properly.  Fixed.
   - Fix non selectable inbox.
   - Add src/configtest.php script which checks for common errors in the config.
   - sqimap_create_stream() was not obeying passed params properly.  Fixed.
   - Fix non selectable inbox.
   - Add src/configtest.php script which checks for common errors in the config.
+  - Improve display of some unparsable/absent dates (#891354).
   
 
 Version 1.5.0
   
 
 Version 1.5.0
index 7ecb86bbe2617ffb2a681500bf9df1a4f6591aa3..9f106d86b62d334ede869a4062f9666dc1e1a23f 100644 (file)
@@ -17,7 +17,7 @@
  * @package squirrelmail
  */
 class Rfc822Header {
  * @package squirrelmail
  */
 class Rfc822Header {
-    var $date = '',
+    var $date = -1,
         $subject = '',
         $from = array(),
         $sender = '',
         $subject = '',
         $from = array(),
         $sender = '',
@@ -45,12 +45,12 @@ class Rfc822Header {
         if (is_array($hdr)) {
             $hdr = implode('', $hdr);
         }
         if (is_array($hdr)) {
             $hdr = implode('', $hdr);
         }
-        /* First we unfold the header */
-        $hdr = trim(str_replace(array("\r\n\t", "\r\n "),array(' ', ' '), $hdr));
+        /* First we replace \r\n by \n and unfold the header */
+        $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $hdr));
 
         /* Now we can make a new header array with */
         /* each element representing a headerline  */
 
         /* Now we can make a new header array with */
         /* each element representing a headerline  */
-        $hdr = explode("\r\n" , $hdr);
+        $hdr = explode("\n" , $hdr);
         foreach ($hdr as $line) {
             $pos = strpos($line, ':');
             if ($pos > 0) {
         foreach ($hdr as $line) {
             $pos = strpos($line, ':');
             if ($pos > 0) {
index 84029fc18438b39d40ec82a441c9072c739905a4..c6b5db95be3318d3edfb5b679a0fedc8f65dd9a9 100644 (file)
@@ -398,7 +398,7 @@ function getTimeStamp($dateParts) {
      * Since the day of week is optional, this check is needed.
      */
      if (count($dateParts) <2) {
      * Since the day of week is optional, this check is needed.
      */
      if (count($dateParts) <2) {
-        return 0;
+        return -1;
      }
 
     /* remove day of week */
      }
 
     /* remove day of week */
index cbfd233b512e341a48762b4c524cfe85cf4ce4dd..23bb1ac28a0a2bd71cc910cfff989eb1ac0ca726 100755 (executable)
@@ -530,11 +530,15 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false)
     $i = 0;
     
     foreach ($read_list as $r) {
     $i = 0;
     
     foreach ($read_list as $r) {
+        /* initialize/reset vars */
         $subject = _("(no subject)");
         $from = _("Unknown sender");
         $priority = 0;
         $messageid = '<>';
         $subject = _("(no subject)");
         $from = _("Unknown sender");
         $priority = 0;
         $messageid = '<>';
-        $cc = $to = $date = $type[0] = $type[1] = $inrepto = '';
+       $type = array('','');
+        $cc = $to = $inrepto = '';
+        // use unset because we do isset below
+        unset($date);
         $flag_seen = $flag_answered = $flag_deleted = $flag_flagged = false;
 
         $read = implode('',$r);
         $flag_seen = $flag_answered = $flag_deleted = $flag_flagged = false;
 
         $read = implode('',$r);
@@ -622,11 +626,11 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false)
                 $i = strpos($read,'{',$i);
                 $header = parseString($read,$i);
                 if ($header === false) break 3;
                 $i = strpos($read,'{',$i);
                 $header = parseString($read,$i);
                 if ($header === false) break 3;
-                /* First we unfold the header */
-                $hdr = trim(str_replace(array("\r\n\t", "\r\n "),array(' ', ' '), $header));
+                /* First we replace all \r\n by \n, and unfold the header */
+                $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $header));
                 /* Now we can make a new header array with */
                 /* each element representing a headerline  */
                 /* Now we can make a new header array with */
                 /* each element representing a headerline  */
-                $hdr = explode("\r\n" , $hdr);
+                $hdr = explode("\n" , $hdr);
                 foreach ($hdr as $line) {
                     $pos = strpos($line, ':');
                     if ($pos > 0) {
                 foreach ($hdr as $line) {
                     $pos = strpos($line, ':');
                     if ($pos > 0) {
@@ -655,9 +659,6 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false)
                                 if(!is_array($type)) {
                                     $type[0] = 'text';
                                 }
                                 if(!is_array($type)) {
                                     $type[0] = 'text';
                                 }
-                                if (!isset($type[1])) {
-                                    $type[1] = '';
-                                }
                                 break;
                             default: break;
                             }
                                 break;
                             default: break;
                             }
@@ -674,7 +675,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false)
             $date = str_replace('  ', ' ', $date);
             $tmpdate  = explode(' ', trim($date));
         } else {
             $date = str_replace('  ', ' ', $date);
             $tmpdate  = explode(' ', trim($date));
         } else {
-            $tmpdate = $date = array('', '', '', '', '', '');
+            $tmpdate = $date = array();
         }
         if ($uid_support) {
             $msgi ="$unique_id";
         }
         if ($uid_support) {
             $msgi ="$unique_id";