Subject: | is_parent bad arrayref and Massage needs to quote additional characters |
Two problems are addressed in the bug report (sorry, perhaps technically
I should have split these out):
* [Issue#1] If list() returns undef when called in is_parent, $list does
not contain an arrayref thus @$list is invalid. In my case, this
happened via a call to selectable().
Error seen would be something like:
Use of uninitialized value in pattern match (m//) at
.../lib/Mail/IMAPClient.pm line 2303.
* [Issue#2] Massage has (for a long time) only quoted for a limited
number of cases, but most (if not all?) IMAP want certain special
characters to be quoted more often. For example, any folder name
containing an asterisk should be quoted if I read the RFC's correctly.
Here's my RFC interpretation of what should be quoted (also included in
patch):
# rfc3501:
# atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
# quoted-specials / resp-specials
# list-wildcards = "%" / "*"
# quoted-specials = DQUOTE / "\"
# resp-specials = "]"
# rfc2060: CTL ::= <any ASCII control character and DEL, 0x00 - 0x1f, 0x7f>
Another approach that at least Thunderbird seems to take is quote
anything that isn't going to be sent as a literal (not sure if/when
thunderbird will even use a literal)... or we can just use the updated
regexp in the patch. Either would suffice.
Without quoting, I would get errors like:
33 CREATE Star*
33 BAD parse error: excess characters at end of command
A patch is attached!
PS. If you're looking for a co-maintainer let me know!
Subject: | imapclient-3.13.bad_ref-fix_quote.patch |
--- IMAPClient.pm.ORIG 2009-01-06 04:01:22.000000000 -0500
+++ IMAPClient.pm 2009-01-31 01:38:39.000000000 -0500
@@ -2255,7 +2255,7 @@
sub is_parent
{ my ($self, $folder) = (shift, shift);
- my $list = $self->list(undef, $folder) || "NO NO BAD BAD";
+ my $list = $self->list(undef, $folder) || return undef;
my $line;
for(my $m = 0; $m < @$list; $m++)
@@ -2300,7 +2300,8 @@
sub selectable
{ my ($self, $f) = @_;
- not( grep /NoSelect/i, $self->list("", $f) );
+ my $list = $self->list("", $f) or return undef;
+ not( grep /NoSelect/i, @$list );
}
sub append
@@ -2763,12 +2764,19 @@
sub Quote($) { $_[0]->Massage($_[1], NonFolderArg) }
+# rfc3501:
+# atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
+# quoted-specials / resp-specials
+# list-wildcards = "%" / "*"
+# quoted-specials = DQUOTE / "\"
+# resp-specials = "]"
+# rfc2060: CTL ::= <any ASCII control character and DEL, 0x00 - 0x1f, 0x7f>
sub Massage($;$)
{ my ($self, $name, $notFolder) = @_;
$name =~ s/^\"(.*)\"$/$1/ unless $notFolder;
$name =~ /["\\]/ ? "{".length($name)."}\r\n$name"
- : $name =~ /[\s{}()]/ ? qq["$name"]
+ : $name =~ /[(){}\s[:cntrl:]%\*\[\]]/ ? qq["$name"]
: $name;
}