Skip Menu |

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

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

People
Owner: PLOBBES [...] cpan.org
Requestors: bpkroth [...] gmail.com
Cc:
AdminCc:

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



Subject: fetch_hash() parse error
Date: Wed, 1 Dec 2010 22:33:20 -0600
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: Brian Kroth <bpkroth [...] gmail.com>
There's actually two issues here. 1) fetch_hash() seems to fail parsing ENVELOPE field values that have certain quote characters in them. 2) fetch_hash() doesn't return X-SAVEDATE fields as requested. Attached is the debug output. Versions involved are as follows: libmail-imapclient-perl 3.25-1 perl 5.10.1-16 Debian Squeeze Here's a snippit from the code: # Connect ... # Fetch mailboxes. my @mboxes = $imap->folders() or die("ERROR: Failed to LIST:\n$@\n"); foreach my $mbox (@mboxes) { # Select the mailbox. $imap->select($mbox) or die("ERROR: Failed to SELECT \"$mbox\":\n$@\n"); # Search for UIDs that are marked as deleted. my @uids = $imap->search('DELETED'); if (scalar(@uids) > 0) { my $uid_list = $imap->Range(@uids); # Get the date info on those uids. my @old_uids; my @fetch_fields = ('UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE'); my %old_msg_data = $imap->fetch_hash($uid_list, @fetch_fields) or die("ERROR: Failed to FETCH message data on DELETED UIDs $uid_list:\n$@\n"); print "Found the following DELETED message data:\n", Dumper(\%old_msg_data); # Do stuff with that message data ... } } # Disconnect ... Let me know if you need anything else. Thanks, Brian

Message body is not shown because sender requested not to inline it.

Download signature.asc
application/pgp-signature 197b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #63524] AutoReply: fetch_hash() parse error
Date: Thu, 2 Dec 2010 09:40:45 -0600
To: Bugs in Mail-IMAPClient via RT <bug-Mail-IMAPClient [...] rt.cpan.org>
From: Brian Kroth <bpkroth [...] gmail.com>
Show quoted text
> There's actually two issues here. > > 1) fetch_hash() seems to fail parsing ENVELOPE field values that have > certain quote characters in them. > > 2) fetch_hash() doesn't return X-SAVEDATE fields as requested. > > Attached is the debug output. > Versions involved are as follows: > libmail-imapclient-perl 3.25-1 > perl 5.10.1-16 > Debian Squeeze > > Here's a snippit from the code: > > # Connect ... > # Fetch mailboxes. > my @mboxes = $imap->folders() or die("ERROR: Failed to LIST:\n$@\n"); > foreach my $mbox (@mboxes) { > # Select the mailbox. > $imap->select($mbox) or die("ERROR: Failed to SELECT \"$mbox\":\n$@\n"); > # Search for UIDs that are marked as deleted. > my @uids = $imap->search('DELETED'); > if (scalar(@uids) > 0) { > my $uid_list = $imap->Range(@uids); > # Get the date info on those uids. > my @old_uids; > my @fetch_fields = ('UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE'); > my %old_msg_data = $imap->fetch_hash($uid_list, @fetch_fields) > or die("ERROR: Failed to FETCH message data on DELETED UIDs $uid_list:\n$@\n"); > print "Found the following DELETED message data:\n", Dumper(\%old_msg_data); > # Do stuff with that message data ...
In working around this, I found that if instead of the above $imap->fetch_hash() code I do the following: my @lines = $imap->fetch($uid_list, @fetch_fields); Then I get the following problems: 1) Multi-line string literals {nnn} are not replaced and concatenated as the documentation reports. 2) I can't call the function as shown above, else I get a BAD response from IMAP (see below). Instead I have to do the following (basically compose the IMAP message myself): @lines = $imap->fetch($uid_list, '('.join(' ', @fetch_fields).')'); Show quoted text
> } > } > # Disconnect ... > > Let me know if you need anything else. > > Thanks, > Brian
Sending: 19 UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE Sent 53 bytes Read: 19 BAD Error in IMAP command UID FETCH: Invalid arguments. ERROR: 19 BAD Error in IMAP command UID FETCH: Invalid arguments. at /usr/share/perl5/Mail/IMAPClient.pm line 1457 Mail::IMAPClient::_get_response('Mail::IMAPClient=HASH(0x2922498)', 19, undef) called at /usr/share/perl5/Mail/IMAPClient.pm line 1406 Mail::IMAPClient::_imap_command_do('Mail::IMAPClient=HASH(0x2922498)', 'UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 1312 Mail::IMAPClient::_imap_command('Mail::IMAPClient=HASH(0x2922498)', 'UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 1488 Mail::IMAPClient::_imap_uid_command('Mail::IMAPClient=HASH(0x2922498)', 'FETCH', '12:13,17', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 2107 Mail::IMAPClient::fetch('Mail::IMAPClient=HASH(0x2922498)', 'Mail::IMAPClient::MessageSet=SCALAR(0x282ffe0)', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at ./dovecot-maintenance-v4.pl line 154 ERROR: 19 BAD Error in IMAP command UID FETCH: Invalid arguments. at /usr/share/perl5/Mail/IMAPClient.pm line 1357 Mail::IMAPClient::_imap_command('Mail::IMAPClient=HASH(0x2922498)', 'UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 1488 Mail::IMAPClient::_imap_uid_command('Mail::IMAPClient=HASH(0x2922498)', 'FETCH', '12:13,17', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 2107 Mail::IMAPClient::fetch('Mail::IMAPClient=HASH(0x2922498)', 'Mail::IMAPClient::MessageSet=SCALAR(0x282ffe0)', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at ./dovecot-maintenance-v4.pl line 154 Use of uninitialized value $line in pattern match (m//) at ./dovecot-maintenance-v4.pl line 160. Use of uninitialized value $line in pattern match (m//) at ./dovecot-maintenance-v4.pl line 160. Use of uninitialized value $line in concatenation (.) or string at ./dovecot-maintenance-v4.pl line 165.
Download signature.asc
application/pgp-signature 197b

Message body not shown because it is not plain text.

Thanks for the bug report, we clearly have a few bugs to clean up here... On Thu Dec 02 10:41:23 2010, bpkroth@gmail.com wrote: Show quoted text
> > There's actually two issues here. > > > > 1) fetch_hash() seems to fail parsing ENVELOPE field values that > > have certain quote characters in them.
Clearly a bug here. If you get a chance to write a test case based on the problem that would be great. See t/fetch_hash.t for a starting point if you are interested, otherwise I'll do this when I get a little time. Show quoted text
> > 2) fetch_hash() doesn't return X-SAVEDATE fields as requested.
I just did a very quick glance at the code and I don't see why this would be the case but perhaps this is related to the issue in #1. [...snip...] Show quoted text
> In working around this, I found that if instead of the above > $imap->fetch_hash() code I do the following: > my @lines = $imap->fetch($uid_list, @fetch_fields); > > Then I get the following problems: > > 1) Multi-line string literals {nnn} are not replaced and concatenated > as the documentation reports.
Can you provide a little more detail here? The output from fetch() is "raw" per the original code from the original author. Are you saying you're still seeing "{nnn}" interspersed in with the actual data? Show quoted text
> 2) I can't call the function as shown above, else I get a BAD response > from IMAP (see below). Instead I have to do the following (basically > compose the IMAP message myself): > @lines = $imap->fetch($uid_list, '('.join(' ', @fetch_fields).')');
Clearly a bug.
CC: DJKERNEN__NO_SOLICITING__ [...] cpan.org
Subject: Re: [rt.cpan.org #63524] fetch_hash() parse error
Date: Thu, 2 Dec 2010 13:43:57 -0600
To: "Phil Pearl (Lobbes) via RT" <bug-Mail-IMAPClient [...] rt.cpan.org>
From: Brian Kroth <bpkroth [...] gmail.com>
Phil Pearl (Lobbes) via RT <bug-Mail-IMAPClient@rt.cpan.org> 2010-12-02 12:00: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=63524 > > > Thanks for the bug report, we clearly have a few bugs to clean up here... > > On Thu Dec 02 10:41:23 2010, bpkroth@gmail.com wrote:
> > > There's actually two issues here. > > > > > > 1) fetch_hash() seems to fail parsing ENVELOPE field values that > > > have certain quote characters in them.
> > Clearly a bug here. If you get a chance to write a test case based > on the problem that would be great. See t/fetch_hash.t for a starting > point if you are interested, otherwise I'll do this when I get a little > time.
The test case was basically a message with the following subject line: foo "bar" baz's Then I FETCH (ENVELOPE) of the messages from that mailbox and it gets angry while parsing it. Show quoted text
> Can you provide a little more detail here? The output from fetch() is > "raw" per the original code from the original author. Are you saying > you're still seeing "{nnn}" interspersed in with the actual data?
As I read the docs [1] I would expect a response like this: * FETCH 10 (UID 6 ENVELOPE (some-date {15} foo "bar" baz's "other-properly-quoted-junk")) To be turned into this: * FETCH 10 (UID 6 ENVELOPE (some-date foo "bar" baz's "other-properly-quoted-junk")) Instead they come out like this: * FETCH 10 (UID 6 ENVELOPE (some-date foo "bar" baz's "other-properly-quoted-junk")) I hope that makes sense. Thanks, Brian [1] http://search.cpan.org/~plobbes/Mail-IMAPClient/lib/Mail/IMAPClient.pod#fetch "The only exception to this is literal strings, which will be inserted into the output line at the point at which they were encountered (without the {nnn} literal field indicator)"
Download signature.asc
application/pgp-signature 197b

Message body not shown because it is not plain text.

I am preparing to release Mail::IMAPClient 3.26 soon and I have fixed the two issues you reported. Here are the related Changelog entries: - rt.cpan.org#63524: fetch_hash() parse errors [Brian Kroth] + fixed handling of LITERAL values in response + fixed handling of field names with a dash (e.g. X-SAVEDATE) + fetch_hash now uses Escaped_results() method - *fixed Escaped_results() to properly join LITERAL data with the data that comes before and after it Once the new version is released (hopefully next week) please try it out and let me know if you see any other problems. Thanks again for reporting these issues!
Mail::IMAPClient 3.26 has been released to CPAN. Please install it if you get a chance and let me know if you run into any more problems, thanks!
CC: DJKERNEN__NO_SOLICITING__ [...] cpan.org
Subject: Re: [rt.cpan.org #63524] fetch_hash() parse error
Date: Tue, 1 Feb 2011 13:39:17 -0600
To: "Phil Pearl (Lobbes) via RT" <bug-Mail-IMAPClient [...] rt.cpan.org>
From: Brian Kroth <bpkroth [...] gmail.com>
Phil Pearl (Lobbes) via RT <bug-Mail-IMAPClient@rt.cpan.org> 2011-02-01 09:44: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=63524 > > > Mail::IMAPClient 3.26 has been released to CPAN. Please install it if you > get a chance and let me know if you run into any more problems, thanks!
Looks good to me so far. Thanks, Brian
Download signature.asc
application/pgp-signature 197b

Message body not shown because it is not plain text.