Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 4479
Status: resolved
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: Nobody in particular
Requestors: g [...] netcraft.com.au
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.2.9
Fixed in: (no value)



Subject: BodyStructure parsing failure
Using UW IMAP 2002d I can get a bodystructure from a message that looks like this: 3 fetch 1 bodystructure * 1 FETCH (BODYSTRUCTURE ("AUDIO" "X-WAV" ("NAME" "test.wav") NIL NIL "BASE64" 144386 NIL ("INLINE" ("FILENAME" "test.wav")) NIL NIL)) Putting that through Mail::IMAPClient 2.2.9 with Parse::RecDescent 1.80 it fails. The following code: use Mail::IMAPClient::BodyStructure; print "test 1 failed\n" unless Mail::IMAPClient::BodyStructure->new('* 7 FETCH (UID 51 BODYSTRUCTURE ("AUDIO" "X-WAV" ("NAME" "test.wav") NIL NIL "BASE64" 53738 NIL ("INLINE" ("FILENAME" "test.wav")) NIL NIL))'); print "test 2 failed\n" unless Mail::IMAPClient::BodyStructure->new('* 7 FETCH (UID 51 BODYSTRUCTURE ("AUDIO" "X-WAV" ("NAME" "test.wav") NIL NIL "BASE64" 53738 NIL ("INLINE" ("FILENAME" "test.wav")) NIL))'); prints "test 1 failed". Note that the removal of the last "NIL" causes the parse to succeed. Running the above code with $::RD_TRACE = 1 shows the string "NIL))" remaining at the end. Unfortunately I don't know enough about IMAP to determine whether this is a UW IMAP bug or a Mail::IMAPClient bug. If it's the former, it would still be nice if Mail::IMAPClient could work with it. Some other possibly useful info: perl -v: This is perl, v5.8.1 built for i386-linux-thread-multi uname -a: Linux localhost 2.4.22-1.2115.nptl #1 Wed Oct 29 15:42:51 EST 2003 i686 i686 i386 GNU/Linux Thanks, Geoffrey D. Bennett
New maintainer Did you figure-out what was wrong? Or should I still investigate this problem? On Tue Nov 25 08:43:15 2003, guest wrote: Show quoted text
> Using UW IMAP 2002d I can get a bodystructure from a message that > looks like this: > > 3 fetch 1 bodystructure > * 1 FETCH (BODYSTRUCTURE ("AUDIO" "X-WAV" ("NAME" "test.wav") NIL NIL > "BASE64" 144386 NIL ("INLINE" ("FILENAME" "test.wav")) NIL NIL)) > > Putting that through Mail::IMAPClient 2.2.9 with Parse::RecDescent > 1.80 it fails. The following code: > > use Mail::IMAPClient::BodyStructure; > > print "test 1 failed\n" unless Mail::IMAPClient::BodyStructure->new('* > 7 FETCH (UID 51 BODYSTRUCTURE ("AUDIO" "X-WAV" ("NAME" "test.wav") > NIL NIL "BASE64" 53738 NIL ("INLINE" ("FILENAME" "test.wav")) NIL > NIL))'); > print "test 2 failed\n" unless Mail::IMAPClient::BodyStructure->new('* > 7 FETCH (UID 51 BODYSTRUCTURE ("AUDIO" "X-WAV" ("NAME" "test.wav") > NIL NIL "BASE64" 53738 NIL ("INLINE" ("FILENAME" "test.wav")) > NIL))'); > > prints "test 1 failed". Note that the removal of the last "NIL" > causes the parse to succeed. > > Running the above code with $::RD_TRACE = 1 shows the string "NIL))" > remaining at the end. > > Unfortunately I don't know enough about IMAP to determine whether this > is a UW IMAP bug or a Mail::IMAPClient bug. If it's the former, it > would still be nice if Mail::IMAPClient could work with it. > > Some other possibly useful info: > perl -v: This is perl, v5.8.1 built for i386-linux-thread-multi > uname -a: Linux localhost 2.4.22-1.2115.nptl #1 Wed Oct 29 15:42:51 > EST 2003 i686 i686 i386 GNU/Linux > > Thanks, > Geoffrey D. Bennett
From: GRICHTER [...] cpan.org
On Mi. 24. Okt. 2007, 13:29:58, MARKOV wrote: Show quoted text
> New maintainer > > Did you figure-out what was wrong? Or should I still investigate > this problem? >
I just run over the same bug (cyrus-imapd 2.3.10). So it's still there in 2.99_04. Reading the RFC giving me the impression that after the body langunge, there could be any number of optional parameters. So I added this to the parser grammer (diff is append). I don't know too much of the details of imap, but it works for me and at the first look it seems to be the correct solution. In addation I had to change the line 1568 im IMAPClient.pm from my $output = grep /BODYSTRUCTURE \(/i, @out; # Wee! ;-) to my ($output) = grep /BODYSTRUCTURE \(/i, @out; # Wee! ;-) Gerald
--- lib/Mail/IMAPClient/BodyStructure/Parse.grammar.orig 2007-11-11 20:44:49.000000000 +0100 +++ lib/Mail/IMAPClient/BodyStructure/Parse.grammar 2007-11-11 20:44:49.000000000 +0100 @@ -103,6 +103,8 @@ { $return = $item{NIL} || $item{STRING} ;$return||defined($return);} bodylang: NIL | STRING | "(" STRING(s) ")" { $return = $item{NIL} || $item{'STRING(s)'} ;$return||defined($return);} +bodyextra: NIL | STRING | "(" STRING(s) ")" + { 0 } personalname: NIL | STRING { $return = $item{NIL} || $item{STRING} ;$return||defined($return);} sourceroute: NIL | STRING @@ -189,20 +191,20 @@ $return; } -textmessage: TEXT <commit> basicfields textlines(?) bodyMD5(?) bodydisp(?) bodylang(?) +textmessage: TEXT <commit> basicfields textlines(?) bodyMD5(?) bodydisp(?) bodylang(?) bodyextra(?) { $return = $item{basicfields}||{}; $return->{bodytype} = 'TEXT'; - foreach my $what (qw/textlines(?) bodyMD5(?) bodydisp(?) bodylang(?)/) { + foreach my $what (qw/textlines(?) bodyMD5(?) bodydisp(?) bodylang(?) bodyextra(?)/) { my $k = $what; $k =~ s/\(\?\)$//; ref($item{$what}) and $return->{$k} = $item{$what}[0]; } $return||defined($return); } -othertypemessage: bodytype basicfields bodyparms(?) bodydisp(?) bodylang(?) +othertypemessage: bodytype basicfields bodyparms(?) bodydisp(?) bodylang(?) bodyextra(?) { $return = {}; - foreach my $what (qw/bodytype bodyparms(?) bodydisp(?) bodylang(?)/) { + foreach my $what (qw/bodytype bodyparms(?) bodydisp(?) bodylang(?) bodyextra(?)/) { my $k = $what; $k =~ s/\(\?\)$//; $return->{$k} = ref($item{$what})? $item{$what}[0] : $item{$what} ; } @@ -213,12 +215,12 @@ messagerfc822message: rfc822message <commit> bodyparms bodyid bodydesc bodyenc bodysize envelopestruct bodystructure textlines - bodyMD5(?) bodydisp(?) bodylang(?) + bodyMD5(?) bodydisp(?) bodylang(?) bodyextra(?) { $return = {}; foreach my $what (qw/ bodyparms bodyid bodydesc bodyenc bodysize envelopestruct bodystructure textlines - bodyMD5(?) bodydisp(?) bodylang(?) + bodyMD5(?) bodydisp(?) bodylang(?) bodyextra(?) / ) { my $k = $what; $k =~ s/\(\?\)$//; @@ -240,14 +242,14 @@ part: subpart(s) <commit> basicfields - bodyparms(?) bodydisp(?) bodylang(?) + bodyparms(?) bodydisp(?) bodylang(?) bodyextra(?) <defer: $subpartCount = 0> { $return = bless($item{basicfields}, "Mail::IMAPClient::BodyStructure"); $return->{bodytype} = "MULTIPART"; $return->{bodystructure} = $item{'subpart(s)'}; - foreach my $b (qw/bodyparms(?) bodydisp(?) bodylang(?)/) { + foreach my $b (qw/bodyparms(?) bodydisp(?) bodylang(?) bodyextra(?)/) { my $k = $b; $k =~ s/\(\?\)$//; $return->{$k} = ref($item{$b}) ? $item{$b}[0] : $item{$b}; }
Subject: Re: [rt.cpan.org #4479] BodyStructure parsing failure
Date: Mon, 12 Nov 2007 15:16:37 +0100
To: Gerald_Richter via RT <bug-Mail-IMAPClient [...] rt.cpan.org>
From: NLnet webmaster <webmaster [...] nlnet.nl>
* Gerald_Richter via RT (bug-Mail-IMAPClient@rt.cpan.org) [071111 19:54]: Show quoted text
> I just run over the same bug (cyrus-imapd 2.3.10). So it's still there > in 2.99_04. > > Reading the RFC giving me the impression that after the body langunge, > there could be any number of optional parameters.
The RFC is vague, but defined by reality ;-) Show quoted text
> > So I added this to the parser grammer (diff is append). I don't know too > much of the details of imap, but it works for me and at the first look > it seems to be the correct solution.
Good work! (gladly someone understand it!) Show quoted text
> In addation I had to change the line 1568 im IMAPClient.pm from > my $output = grep /BODYSTRUCTURE \(/i, @out; # Wee! ;-) > to > > my ($output) = grep /BODYSTRUCTURE \(/i, @out; # Wee! ;-)
I've changed this into my $output = first {$_ =~ /BODYSTRUCTURE \(/i} @out; # Wee! ;-) Thanks -- MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
should be fixed in 2.99_06, so closed