Skip Menu |

This queue is for tickets about the Net-IMAP-Client CPAN distribution.

Report information
The Basics
Id: 69467
Status: resolved
Priority: 0/
Queue: Net-IMAP-Client

People
Owner: Nobody in particular
Requestors: mss [...] apache.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.95
Fixed in: (no value)



Subject: get_summaries fails to parse complex reply
The simple script below fails with the error Odd number of elements in hash assignment at /usr/share/perl5/Net/IMAP/Client.pm line 389, <GEN0> line 14. Can't call method "message_id" on unblessed reference at ./imap.pl line 24, <GEN0> line 14. Looks like _parse_token fails to parse the complex reply which I attached (redacted for privacy). Net::IMAP::Client: 0.95 Perl: 5.10.1 OS: Linux TreeHouse 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux IMAP Server: [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. See COPYING for distribution information. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Net::IMAP::Client; my $imap = Net::IMAP::Client->new( server => $ARGV[0], user => $ARGV[1], pass => $ARGV[2], ) or die; $imap->login() or die $imap->last_error; $imap->select('INBOX'); my $messages = $imap->search('ALL'); my %ids; foreach my $m (@$messages) { my $id = $imap->get_summaries($m, 'Message-Id')->message_id; $ids{$id} = $m; } print Dumper(\%ids);
Subject: imap.txt
NIC4 UID FETCH 190 (UID FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODYSTRUCTURE BODY.PEEK[HEADER.FIELDS (Message-Id)]) * 1 FETCH (UID 190 FLAGS (\Seen) INTERNALDATE "13-Jun-2011 13:45:39 +0200" RFC822.SIZE 3228655 ENVELOPE ("Mon, 13 Jun 2011 13:45:00 +0200" "LLLLLLL / IIIIIIIIII pictures" (("LLLLLLL" NIL "bbbbblllllll" "gmail.com")) (("LLLLLLL" NIL "bbbbblllllll" "gmail.com")) (("LLLLLLL" NIL "bbbbblllllll" "gmail.com")) (("'LLLLLLL, Oooooo Nnnn'" NIL "oooooo.nnnn" "lllllll.de")) (("'LLLLLLL, Sssssss Gggggggggg'" NIL "sssssss.gggggggggg" "lllllll.de")("'Hh, Jjjjjj'" NIL "hh" "lllllll.com.cn")("'LLLLLLL,JP '" NIL "jjjj_pppp" "lllllll.com.cn")("'Iiiiiii Lllllll'" NIL "iiiiiii.lllllll" "lllllll.de")) NIL NIL "<002a01cc29bf$5536d150$ffa473f0$@com>") BODYSTRUCTURE (((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 993 37 NIL NIL NIL)("text" "html" ("charset" "us-ascii") NIL NIL "quoted-printable" 4584 105 NIL NIL NIL) "alternative" ("boundary" "----=_NextPart_002_002D_01CC29D0.18BFC860") NIL NIL)("image" "png" ("name" "image001.png") "<image001.png@01CC29D0.10207240>" NIL "base64" 3376 NIL NIL NIL) "related" ("boundary" "----=_NextPart_001_002C_01CC29D0.18BFC860") NIL NIL)("image" "jpeg" ("name" "IMG_2956 (Medium).JPG") NIL NIL "base64" 181446 NIL ("attachment" ("filename" "IMG_2956 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2957 (Medium).JPG") NIL NIL "base64" 181688 NIL ("attachment" ("filename" "IMG_2957 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2958 (Medium).JPG") NIL NIL "base64" 164326 NIL ("attachment" ("filename" "IMG_2958 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2959 (Medium).JPG") NIL NIL "base64" 208968 NIL ("attachment" ("filename" "IMG_2959 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2961 (Medium).JPG") NIL NIL "base64" 165526 NIL ("attachment" ("filename" "IMG_2961 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2964 (Medium).JPG") NIL NIL "base64" 203590 NIL ("attachment" ("filename" "IMG_2964 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2967 (Medium).JPG") NIL NIL "base64" 184122 NIL ("attachment" ("filename" "IMG_2967 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2968 (Medium).JPG") NIL NIL "base64" 220490 NIL ("attachment" ("filename" "IMG_2968 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2972 (Medium).JPG") NIL NIL "base64" 195716 NIL ("attachment" ("filename" "IMG_2972 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2974 (Medium).JPG") NIL NIL "base64" 219436 NIL ("attachment" ("filename" "IMG_2974 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2978 (Medium).JPG") NIL NIL "base64" 179392 NIL ("attachment" ("filename" "IMG_2978 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_2993 (Medium).JPG") NIL NIL "base64" 179310 NIL ("attachment" ("filename" "IMG_2993 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_3002 (Medium).JPG") NIL NIL "base64" 199456 NIL ("attachment" ("filename" "IMG_3002 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_3010 (Medium).JPG") NIL NIL "base64" 110058 NIL ("attachment" ("filename" "IMG_3010 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_3015 (Medium).JPG") NIL NIL "base64" 223180 NIL ("attachment" ("filename" "IMG_3015 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_3032 (Medium).JPG") NIL NIL "base64" 192530 NIL ("attachment" ("filename" "IMG_3032 (Medium).JPG")) NIL)("image" "jpeg" ("name" "IMG_3035 (Medium).JPG") NIL NIL "base64" 203256 NIL ("attachment" ("filename" "IMG_3035 (Medium).JPG")) NIL) "mixed" ("boundary" "----=_NextPart_000_002B_01CC29D0.18BFA150") NIL "de") BODY[HEADER.FIELDS ("Message-Id")] {53} Message-ID: <002a01cc29bf$5536d150$ffa473f0$@com> ) NIC4 OK FETCH completed.
From: mss [...] apache.org
On Thu Jul 14 07:17:51 2011, I wrote: Show quoted text
> The simple script below fails with the error
Now, an even simpler fetch() call fails the same. I used the code suggested in the documentation my $h = "BODY[HEADER.FIELDS (Message-Id)]"; my %ids; foreach my $m (@$messages) { my $id = $imap->fetch($m, $h)->{$h}; $ids{$id} = $m; } and got Odd number of elements in anonymous hash at /usr/share/perl5/Net/IMAP/Client.pm line 426, <GEN0> line 14. I added a simple print join(" :: ", @$tokens) . "\n"; below that line and got UID :: 190 :: BODY :: ARRAY(0x2955088) :: Message-ID: <002a01cc29bf$5536d150$ffa473f0$@com> So the actual problem is that if you specify these additional attributes, _parsetoken will return the additional fields unparsed/unsplit. I guess the key should be added afterwards or something.
On Thu Jul 14 07:17:51 2011, mss@apache.org wrote: Show quoted text
> The simple script below fails with the error > > Odd number of elements in hash assignment at > /usr/share/perl5/Net/IMAP/Client.pm line 389, <GEN0> line 14. > Can't call method "message_id" on unblessed reference at ./imap.pl line > 24, <GEN0> line 14. > > Looks like _parse_token fails to parse the complex reply which I > attached (redacted for privacy). > > Net::IMAP::Client: 0.95 > Perl: 5.10.1 > OS: Linux TreeHouse 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 > UTC 2011 x86_64 x86_64 x86_64 GNU/Linux > IMAP Server: [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE > THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION > STARTTLS] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. > See COPYING for distribution information. > > #!/usr/bin/perl > use strict; > use warnings; > > use Data::Dumper; > > use Net::IMAP::Client; > > my $imap = Net::IMAP::Client->new( > server => $ARGV[0], > user => $ARGV[1], > pass => $ARGV[2], > > ) or die; > > $imap->login() or die $imap->last_error; > > $imap->select('INBOX'); > my $messages = $imap->search('ALL'); > > my %ids; > foreach my $m (@$messages) { > my $id = $imap->get_summaries($m, 'Message-Id')->message_id; > $ids{$id} = $m; > } > > print Dumper(\%ids);
Hi, get_summaries() returns an ARRAY of summary objects. In your code above, message_id() operates on the ARRAY ref, not on individual objects. To print the Message-ID headers, this code will work. my $messages = $imap->search('ALL'); my $summaries = $imap->get_summaries($messages); map { print $_->message_id, "\n" } @$summaries; Regards, Joel
Subject: get_summaries fails to parse complex reply (status set to resolved)
On Sun Aug 07 20:57:22 2011, ganglion wrote: Show quoted text
> On Thu Jul 14 07:17:51 2011, mss@apache.org wrote:
> > The simple script below fails with the error > > > > Odd number of elements in hash assignment at > > /usr/share/perl5/Net/IMAP/Client.pm line 389, <GEN0> line 14. > > Can't call method "message_id" on unblessed reference at ./imap.pl line > > 24, <GEN0> line 14. > > > > Looks like _parse_token fails to parse the complex reply which I > > attached (redacted for privacy). > > > > Net::IMAP::Client: 0.95 > > Perl: 5.10.1 > > OS: Linux TreeHouse 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 > > UTC 2011 x86_64 x86_64 x86_64 GNU/Linux > > IMAP Server: [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE > > THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION > > STARTTLS] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. > > See COPYING for distribution information. > > > > #!/usr/bin/perl > > use strict; > > use warnings; > > > > use Data::Dumper; > > > > use Net::IMAP::Client; > > > > my $imap = Net::IMAP::Client->new( > > server => $ARGV[0], > > user => $ARGV[1], > > pass => $ARGV[2], > > > > ) or die; > > > > $imap->login() or die $imap->last_error; > > > > $imap->select('INBOX'); > > my $messages = $imap->search('ALL'); > > > > my %ids; > > foreach my $m (@$messages) { > > my $id = $imap->get_summaries($m, 'Message-Id')->message_id; > > $ids{$id} = $m; > > } > > > > print Dumper(\%ids);
> > Hi, > > get_summaries() returns an ARRAY of summary objects. In your code above, > message_id() operates on the ARRAY ref, not on individual objects. > > To print the Message-ID headers, this code will work. > > my $messages = $imap->search('ALL'); > my $summaries = $imap->get_summaries($messages); > map { print $_->message_id, "\n" } @$summaries; > > Regards, > > Joel > >
Marking as resolved. Thank you.