From 61e56f1bf9e2f4c0cc775e141db2734185b404f9 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 18 May 2008 20:01:49 +0000 Subject: [PATCH] Properly detect attachments --- mailboxes/CHANGELOG | 1 + mailboxes/list_mail.cgi | 37 +++++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/mailboxes/CHANGELOG b/mailboxes/CHANGELOG index da8fcce69..fca071d21 100644 --- a/mailboxes/CHANGELOG +++ b/mailboxes/CHANGELOG @@ -50,3 +50,4 @@ Fixed a bug that broke searching by message body contents. ---- Changes since 1.410 ---- Re-organized the Module Config page to make the first section less crowded. Added an option to skip messages flagged as deleted in a Maildir. +Detection of messages with attachments is now 100% accurate, rather than taking a guess based on the MIME type. diff --git a/mailboxes/list_mail.cgi b/mailboxes/list_mail.cgi index 73c7067f6..d9accc0b6 100755 --- a/mailboxes/list_mail.cgi +++ b/mailboxes/list_mail.cgi @@ -89,28 +89,36 @@ if (@mail) { print &ui_columns_start(\@hcols, 100, 0, \@tds); } -# Show rows for actual mail messages +# Get the mails +@showmail = ( ); for($i=$in{'start'}; $i<@mail && $i<$in{'start'}+$perpage; $i++) { - local $idx = $mail[$i]->{'idx'}; + push(@showmail, $mail[$i]); + } +@hasattach = &mail_has_attachments(\@showmail, $folder); + +# Show rows for actual mail messages +$i = 0; +foreach my $mail (@showmail) { + local $idx = $mail->{'idx'}; local $cols = 0; local @cols; - local $from = $mail[$i]->{'header'}->{$showto ? 'to' : 'from'}; + local $from = $mail->{'header'}->{$showto ? 'to' : 'from'}; $from = $text{'mail_unknown'} if ($from !~ /\S/); push(@cols, &view_mail_link($in{'user'}, $folder, $idx, $from)); if ($config{'show_to'}) { push(@cols, &simplify_from( - $mail[$i]->{'header'}->{$showto ? 'from' : 'to'})); + $mail->{'header'}->{$showto ? 'from' : 'to'})); } - push(@cols, &simplify_date($mail[$i]->{'header'}->{'date'})); - push(@cols, &nice_size($mail[$i]->{'size'}, 1024)); + push(@cols, &simplify_date($mail->{'header'}->{'date'})); + push(@cols, &nice_size($mail->{'size'}, 1024)); local $tbl; $tbl .= "". - "
".&simplify_subject($mail[$i]->{'header'}->{'subject'}). + "
".&simplify_subject($mail->{'header'}->{'subject'}). " "; - if ($mail[$i]->{'header'}->{'content-type'} =~ /multipart\/\S+/i) { + if ($hasattach[$i]) { $tbl .= ""; } - local $p = int($mail[$i]->{'header'}->{'x-priority'}); + local $p = int($mail->{'header'}->{'x-priority'}); if ($p == 1) { $tbl .= " "; } @@ -118,17 +126,17 @@ for($i=$in{'start'}; $i<@mail && $i<$in{'start'}+$perpage; $i++) { $tbl .= " "; } if (!$showto) { - if ($read{$mail[$i]->{'header'}->{'message-id'}} == 2) { + if ($read{$mail->{'header'}->{'message-id'}} == 2) { $tbl .= " "; } - elsif ($read{$mail[$i]->{'header'}->{'message-id'}} == 1) { + elsif ($read{$mail->{'header'}->{'message-id'}} == 1) { $tbl .= " "; } } $tbl .= "
\n"; push(@cols, $tbl); - if (&editable_mail($mail[$i])) { + if (&editable_mail($mail)) { print &ui_checked_columns_row(\@cols, \@tds, "d", $idx); } else { @@ -137,13 +145,14 @@ for($i=$in{'start'}; $i<@mail && $i<$in{'start'}+$perpage; $i++) { if ($config{'show_body'}) { # Show part of the body too - &parse_mail($mail[$i]); - local $data = &mail_preview($mail[$i]); + &parse_mail($mail); + local $data = &mail_preview($mail); if ($data) { print " ", &html_escape($data)," \n"; } } + $i++; } if (@mail) { print &ui_columns_end();