Hi,
So, I've been modifying the cmd_learn driver in markasjunk2 to also restore messages to their original content and save them in the user's inbox, the way that the sa_detach driver does.
It was seeing rcube_message->attachments as a zero-length array even on messages with the paperclip icon; I traced this back to roughly line 432 of rcube_message.php ($Id: rcube_message.php 5261 2011-09-21 12:22:40Z alec $):
// list as attachment as well
if (!empty($mail_part->filename))
$this->attachments[] = $mail_part;
If the message part is a text/plain type (which it shouldn't be, but it is, and I'll fix that too in a bit, $%&#! spamassassin), and the message part does not have a filename, then it doesn't get added to the attachments array.
So there are two ways for me to fix this: I can either have the cmd_learn driver code first check rcube_message->attachments, and if that's a zero-length array, then also check rcube_message->parts, or I can eliminate the filename check from this part of rcube_message.php.
Which approach is more correct? Or is there another way to do this?
Thanks,
On Sat, Oct 22, 2011 at 23:17, Rob Sheldon rob@associatedtechs.com wrote:
If the message part is a text/plain type (which it shouldn't be, but it is, and I'll fix that too in a bit, $%&#! spamassassin), and the message part does not have a filename, then it doesn't get added to the attachments array.
So there are two ways for me to fix this: I can either have the cmd_learn driver code first check rcube_message->attachments, and if that's a zero-length array, then also check rcube_message->parts, or I can eliminate the filename check from this part of rcube_message.php.
Which approach is more correct? Or is there another way to do this?
You should iterate over the rcube_message->parts array or even better over rcube_message->mime_parts which is a flat array with mime part IDs as keys. The attachments list is primarily dedicated for listing "real" attachments in the UI but doesn't contain a complete list of all parts for the reasons you correctly pointed out.
Regards, Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/ BT/aba52c80