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
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 */
* @var mixed
*/
var $date = -1;
+ /**
+ * Date_original header
+ * @var mixed
+ */
+ var $date_unparsed = '';
/**
* Subject header
* @var string
$d = strtr($value, array(' ' => ' '));
$d = explode(' ', $d);
$this->date = getTimeStamp($d);
+ $this->date_unparsed = strtr($value,'<>',' ');
break;
case 'subject':
$this->subject = $value;
$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:
* 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 ) {
$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);
}
/* 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) {
$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... */
}
// part 1 (RFC2298)
- $senton = getLongDateString( $header->date );
+ $senton = getLongDateString( $header->date, $header->date_unparsed );
$to_array = $header->to;
$to = '';
foreach ($to_array as $line) {
$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");