Bug#366480: libnet-imap-perl: IMAP Quota support broken
Mike Beattie
mjb at debian.org
Tue May 9 00:50:06 UTC 2006
Package: libnet-imap-perl
Version: 0.02-3
Severity: important
Using the getquota() method of Net::IMAP doesn't return useful data..
There's a parsing error either in Net::IMAP itself, or Net::xAP within
the parse_fields() method.
The string returned from Cyrus as a result of a getquota call is as
follows:
--> 3 getquota user.xyz
<-- * QUOTA user.xyz (STORAGE 53 51200)
The data structure created within Net::IMAP from this is:
'Quota' => {
'array(0x83c88d0)' => [
undef,
undef
]
},
Where it should be:
'Quota' => {
'STORAGE' => [
53,
51200
]
},
This is a result of this code (/usr/share/perl5/Net/IMAP.pm, line 2615):
my @fields = @{Net::xAP->parse_fields($str)};
$self->{QuotaRoot} = shift(@fields);
while (@fields) {
my ($resource, $usage, $limit) = splice(@fields, 0, 3);
$self->{Quota}{lc($resource)} = [$usage, $limit];
}
Adding a Dumper() call after parse_fields() gives:
$VAR1 = [
'user.xyz',
[
'STORAGE',
'53',
'51200'
]
];
So, it looks like the parse_fields() is parsing the result from the IMAP
server incorrectly (or that the Net::IMAP code is not accounting for
the nested array).
There's a further bug in the access methods:
sub quotas { keys %{$_[0]->{Quotas}} }
sub usage { $_[0]->{Quotas}{lc($_[1])}->[0] }
sub limit { $_[0]->{Quotas}{lc($_[1])}->[1] }
I presume those should be 'Quota', not 'Quotas'. (Or, conversely, the
constructor should use 'Quotas', not 'Quota'.
I guess my hacky solution at this point in time would be to change lines
2618-2619 to read:
my ($resource, $usage, $limit) = @{ shift(@fields) };
$self->{Quotas}{lc($resource)} = [$usage, $limit];
I have not checked this against what the relevant RFC says the response
should be, but I need it going.. I'll leave the correct fix up to you.
Cheers,
Mike.
-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8-3-686-smp
Locale: LANG=en_NZ, LC_CTYPE=en_NZ (charmap=ISO-8859-1)
Versions of packages libnet-imap-perl depends on:
ii libdigest-hmac-perl 1.01-3 create standard message integrity
ii perl [libmime-base64-perl] 5.8.4-8sarge4 Larry Wall's Practical Extraction
-- no debconf information
More information about the pkg-perl-maintainers
mailing list