Skip Menu |

This queue is for tickets about the Email-Store CPAN distribution.

Report information
The Basics
Id: 26885
Status: open
Priority: 0/
Queue: Email-Store

People
Owner: Nobody in particular
Requestors: chisel [...] chizography.net
Cc: cpan [...] herlpacker.co.uk
AdminCc:

Bug Information
Severity: Important
Broken in: 0.255
Fixed in: (no value)



CC: cpan [...] herlpacker.co.uk
Subject: Can't call method "as_string" on an undefined value at lib/Email/Store/Attachment.pm
I think there's a problem with nested mime (eg multipart/alternative + image/jpeg) formatted emails. I don't properly understand the problem (yet), but it looks like some email messages get constructed as two entities, the first being a holding entity for the multipart/alternative message, e.g.: / |-- multipart/alternative |-- text/plain |-- text/html |-- image/jpeg The first entity doesn't have a bodyhandle(), causing the reported error message.
Subject: 60.nested.mime.t
use strict; use warnings; use Test::More tests => 2; use File::Slurp; BEGIN { unlink("t/test.db"); } use Email::Store { only => [qw( Mail Attachment )] }, ("dbi:SQLite:dbname=t/test.db", "", "", { sqlite_handle_binary_nulls => 1 } ); Email::Store->setup; ok(1, "Set up"); my $data = read_file("t/nested-mime"); my $mail = Email::Store::Mail->store($data); my @att = $mail->attachments; is (@att, 2, "Has two attachments");
Subject: nested-mime
Download nested-mime
application/octet-stream 10.5k

Message body not shown because it is not plain text.

The attached patch fixes this issue. The solution is essentially to recurse into multipart attachments. Also, I have replaced ->bodyhandle->as_string with ->body_as_string which also fixed an encoding issue I was having. Hope this helps! Andrew On Wed May 02 07:36:27 2007, CHISEL wrote: Show quoted text
> I think there's a problem with nested mime (eg multipart/alternative + > image/jpeg) formatted emails. > > I don't properly understand the problem (yet), but it looks like some > email messages get constructed as two entities, the first being a > holding entity for the multipart/alternative message, e.g.: > > / > |-- multipart/alternative > |-- text/plain > |-- text/html > |-- image/jpeg > > The first entity doesn't have a bodyhandle(), causing the reported error > message.
Subject: Attachment.pm.diff
24c24,25 < for ($entity->parts) { --- > my @parts = $entity->parts; > for (@parts) { 25a27,30 > if ($_->parts) { > push @parts, $_->parts; > next; > } 28c33 < my $payload = $_->bodyhandle->as_string; --- > my $payload = $_->body_as_string;