Mail-IMAPClient-3.14 message_count
Tod A. Sandman
sandmant at rice.edu
Sat Feb 4 19:21:48 EST 2017
I recently upgraded my cyrus-imapd software and hardware:
Mail-IMAPClient-3.14 -> Mail-IMAPClient-3.37
cyrus-imapd-2.3.16 -> cyrus-imapd-2.5.10
Rhel6 -> Rhel7
and Mail-IMAPClient->message_count() began failing on folder names containing spaces.
I tried 1) escaping the spaces with '\', and 2) using Mail-IMAPClient->Quote, but neither has resolved the issue.
My script creates a Mail-IMAPClient object, searches for a list of folders with Mail-IMAPClient->list, and then, for each element in the list, parses out the folder name (enclosing double quotes included, if present) and calls message_count() on the folder name.
The script works on the old system, spaces or not, but on the new system fails on folder names with spaces.
Perl code snip follows:
defined ($folders = $imap->list ($imap_base, $folder)) or return
LogWarn ("Failure getting Dspam folder list:", $@);
unless (@$folders) {
Show ("No folders found matching \"$folder\".") unless $Quiet;
return $TRUE;
}
foreach $folder (@$folders) {
chomp $folder; $folder =~ s/\r$//;
Show ("Checking folder string \"$folder\".") if $Config{Debug};
if ($folder =~ m:\* LIST .* ("?$imap_base.*"?):) {
$folder = $1;
$folder =~ m:$imap_base([^$separator]+)$separator:;
Show ("Checking folder \"$folder\".") if $Config{Debug};
if ($user = $1) {
..........................
#$msgcount = $imap->message_count($imap->Quote($folder));
$msgcount = $imap->message_count($folder);
unless (defined ($msgcount)) {
if ($Verbose) { ## Fix this
LogWarn ("Could not get message count for folder \"$folder\".");
LogWarn ("Skipping folder \"$folder\":" . $@);
}
return $TRUE;
}
Here is sample output when hitting a folder with spaces:
dspam_folder_train: Checking folder string "* LIST (\HasNoChildren) "/" "user/willr/Inbox Rice/A/DSPAM_spam"".
dspam_folder_train: Checking folder ""user/willr/Inbox Rice/A/DSPAM_spam"".
dspam_folder_train: Could not get message count for folder ""user/willr/Inbox Rice/A/DSPAM_spam"".
dspam_folder_train: Skipping folder ""user/willr/Inbox Rice/A/DSPAM_spam"":
Here I try only escaping spaces:
dspam_folder_train: Could not get message count for folder ""user/willr/Inbox\ Rice/A/DSPAM_spam"".
Here I try escaping spaces and removing enclosing double quotes:
dspam_folder_train: Could not get message count for folder "user/willr/Inbox\ Rice/A/DSPAM_spam".
Any ideas?
Tod Sandman
Sr. Systems Administrator
Office of Information Technology
Rice University
Email: sandmant at rice.edu
More information about the Info-cyrus
mailing list