From: kink Date: Tue, 27 Feb 2007 18:57:18 +0000 (+0000) Subject: also store the unparsed date, and display it when we X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3aaa3214e4a35deff1a5bdfc60e286eec6d75ed2;p=squirrelmail.git also store the unparsed date, and display it when we failed to parse a Date. This allows RFC-incompatible dates to still be seen in e.g. read_body in their original form, better than nothing. For safety split any "<",">" out, something might rely on the date being completely safe to print. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12283 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/class/mime/Message.class.php b/class/mime/Message.class.php index 4bfa29c0..0ecc70f3 100644 --- a/class/mime/Message.class.php +++ b/class/mime/Message.class.php @@ -618,6 +618,7 @@ class Message { if (!$arg_a[1]) $arg_a[1] = _("(no subject)"); $hdr->date = getTimeStamp($d); /* argument 1: date */ + $hdr->date_unparsed = strtr($d,'<>',' '); /* original date */ $hdr->subject = $arg_a[1]; /* argument 2: subject */ $hdr->from = is_array($arg_a[2]) ? $arg_a[2][0] : ''; /* argument 3: from */ $hdr->sender = is_array($arg_a[3]) ? $arg_a[3][0] : ''; /* argument 4: sender */ diff --git a/class/mime/Rfc822Header.class.php b/class/mime/Rfc822Header.class.php index d5095035..f0bd56d9 100644 --- a/class/mime/Rfc822Header.class.php +++ b/class/mime/Rfc822Header.class.php @@ -29,6 +29,11 @@ class Rfc822Header { * @var mixed */ var $date = -1; + /** + * Date_original header + * @var mixed + */ + var $date_unparsed = ''; /** * Subject header * @var string @@ -234,6 +239,7 @@ class Rfc822Header { $d = strtr($value, array(' ' => ' ')); $d = explode(' ', $d); $this->date = getTimeStamp($d); + $this->date_unparsed = strtr($value,'<>',' '); break; case 'subject': $this->subject = $value; @@ -343,7 +349,7 @@ class Rfc822Header { $value = $this->stripComments($value); $this->mlist('id', $value); break; - case 'x-spam-status': + case 'x-spam-status': $this->x_spam_status = $this->parseSpamStatus($value); break; default: diff --git a/functions/date.php b/functions/date.php index 7ed2be7b..d50aa872 100644 --- a/functions/date.php +++ b/functions/date.php @@ -305,14 +305,15 @@ function date_intl( $date_format, $stamp ) { * and taking localization into accout. * * @param int stamp the timestamp + * @param string fallback string to use when stamp not valid * @return string the long date string */ -function getLongDateString( $stamp ) { +function getLongDateString( $stamp, $fallback = '' ) { global $hour_format; if ($stamp == -1) { - return ''; + return $fallback; } if ( $hour_format == SMPREF_TIME_12HR ) { diff --git a/src/compose.php b/src/compose.php index 10b655ca..9e72e917 100644 --- a/src/compose.php +++ b/src/compose.php @@ -285,7 +285,7 @@ function getforwardHeader($orig_header) { $bodyTop = sq_str_pad(' '._("Original Message").' ',$editor_size -2,'-',STR_PAD_BOTH,$default_charset) . "\n". $display[_("Subject")] . $subject . "\n" . $display[_("From")] . $from . "\n" . - $display[_("Date")] . getLongDateString( $orig_header->date ). "\n" . + $display[_("Date")] . getLongDateString( $orig_header->date, $orig_header->date_unparsed ). "\n" . $display[_("To")] . $to . "\n"; if ($orig_header->cc != array() && $orig_header->cc !='') { $cc = decodeHeader($orig_header->getAddr_s('cc',"\n$indent"),false,false,true); @@ -928,7 +928,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } /* this corrects some wrapping/quoting problems on replies */ $rewrap_body = explode("\n", $body); - $from = (is_array($orig_header->from)) ? $orig_header->from[0] : $orig_header->from; + $from = (is_array($orig_header->from) && !empty($orig_header->from)) ? $orig_header->from[0] : $orig_header->from; $body = ''; $strip_sigs = getPref($data_dir, $username, 'strip_sigs'); foreach ($rewrap_body as $line) { diff --git a/src/printer_friendly_bottom.php b/src/printer_friendly_bottom.php index 68143c3c..b65da692 100644 --- a/src/printer_friendly_bottom.php +++ b/src/printer_friendly_bottom.php @@ -52,7 +52,7 @@ if ($passed_ent_id) { $rfc822_header = $message->rfc822_header; /* From and Date are usually fine as they are... */ $from = $rfc822_header->getAddr_s('from'); -$date = getLongDateString($rfc822_header->date); +$date = getLongDateString($rfc822_header->date, $rfc822_header->date_unparsed); $subject = trim($rfc822_header->subject); /* we can clean these up if the list is too long... */ diff --git a/src/read_body.php b/src/read_body.php index 51497411..7ad607ec 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -174,7 +174,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) { } // part 1 (RFC2298) - $senton = getLongDateString( $header->date ); + $senton = getLongDateString( $header->date, $header->date_unparsed ); $to_array = $header->to; $to = ''; foreach ($to_array as $line) { @@ -372,7 +372,7 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $env[_("From")] = _("Unknown sender"); else $env[_("From")] = decodeHeader($from_name); - $env[_("Date")] = getLongDateString($header->date); + $env[_("Date")] = getLongDateString($header->date, $header->date_unparsed); $env[_("To")] = formatRecipientString($header->to, "to"); $env[_("Cc")] = formatRecipientString($header->cc, "cc"); $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");