From: kink Date: Sat, 28 Feb 2004 15:13:17 +0000 (+0000) Subject: Better support for malformed/absent dates and headerlines ending in only "\n". X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=2a9b0fade049f568190407babf869bb4edf23375;hp=85c0ca78ed210ff7680e76c44475cdd1de9da4cf Better support for malformed/absent dates and headerlines ending in only "\n". git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6695 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index 70734e4b..fec652b8 100644 --- 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. + - Improve display of some unparsable/absent dates (#891354). Version 1.5.0 diff --git a/class/mime/Rfc822Header.class.php b/class/mime/Rfc822Header.class.php index 7ecb86bb..9f106d86 100644 --- a/class/mime/Rfc822Header.class.php +++ b/class/mime/Rfc822Header.class.php @@ -17,7 +17,7 @@ * @package squirrelmail */ class Rfc822Header { - var $date = '', + var $date = -1, $subject = '', $from = array(), $sender = '', @@ -45,12 +45,12 @@ class Rfc822Header { 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 */ - $hdr = explode("\r\n" , $hdr); + $hdr = explode("\n" , $hdr); foreach ($hdr as $line) { $pos = strpos($line, ':'); if ($pos > 0) { diff --git a/functions/date.php b/functions/date.php index 84029fc1..c6b5db95 100644 --- a/functions/date.php +++ b/functions/date.php @@ -398,7 +398,7 @@ function getTimeStamp($dateParts) { * Since the day of week is optional, this check is needed. */ if (count($dateParts) <2) { - return 0; + return -1; } /* remove day of week */ diff --git a/functions/imap_messages.php b/functions/imap_messages.php index cbfd233b..23bb1ac2 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -530,11 +530,15 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false) $i = 0; foreach ($read_list as $r) { + /* initialize/reset vars */ $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); @@ -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; - /* 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 */ - $hdr = explode("\r\n" , $hdr); + $hdr = explode("\n" , $hdr); 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 (!isset($type[1])) { - $type[1] = ''; - } 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 { - $tmpdate = $date = array('', '', '', '', '', ''); + $tmpdate = $date = array(); } if ($uid_support) { $msgi ="$unique_id";