Home » Networking » Net_IMAP » Bug #9979
cmdGetACL() fails to parse mailbox with no ACLs
Details
| Submitted | 2007-01-30 17:17 UTC |
|---|---|
| From | s dot e dot grier at qmul dot ac dot uk |
| Assigned | hudeldudel |
| Status | Closed |
| Package | Net_IMAP |
| PHP Version | 5.1.6 |
| OS | FC5 |
| Roadmaps | (Not assigned) |
Comments
[2007-01-30 17:17 UTC] s dot e dot grier at qmul dot ac dot uk
Description:
------------
On my Cyrus mail server I have a mailbox with no ACLs. i.e:
. getacl arts
* ACL arts
. OK Completed
When calling $imap->getACL() on this mailbox, the ACLs are not parsed correctly, nor is the response code. An error like the following appears in the browser:
2826,/usr/share/pear/Net/IMAPProtocol.php,PROTOCOL ERROR!:must be a ' ' but is a '
' !!!!
and $imap->getACL() returns a PEAR_Error object.
This is because IMAPProtocol::_retrParsedResponse() expects an "ACL" response to always have a ACL list, which is not necessarily the case.
Test script:
---------------
<?php
include 'Net/IMAP.php';
$imap = new Net_IMAP("host", "port");
$imap->login("user", "passwd", true, false);
$ret = $imap->getACL("mailbox with no ACLs");
var_dump($ret);
?>
Expected result:
----------------
array(4) {
[0]=>
array(2) {
["USER"]=>
string(6) "tmpusr0"
["RIGHTS"]=>
string(6) "lrswid"
}
[1]=>
array(2) {
["USER"]=>
string(7) "tmpusr1"
["RIGHTS"]=>
string(3) "lrs"
}
[2]=>
array(2) {
["USER"]=>
string(6) "tmpusr2"
["RIGHTS"]=>
string(1) "p"
}
[3]=>
array(2) {
["USER"]=>
string(6) "tmpusr3"
["RIGHTS"]=>
string(6) "lrswid"
}
}
Actual result:
--------------
2825,/usr/share/pear/Net/IMAPProtocol.php,PROTOCOL ERROR!:must be a ' ' but is a '
' !!!!
object(PEAR_Error)#6 (8) {
["error_message_prefix"]=>
string(0) ""
["mode"]=>
int(1)
["level"]=>
int(1024)
["code"]=>
NULL
["message"]=>
string(2) ", "
["userinfo"]=>
NULL
["backtrace"]=>
array(3) {
[0]=>
array(7) {
["file"]=>
string(28) "/usr/share/pear/Net/IMAP.php"
["line"]=>
int(2112)
["function"]=>
string(10) "PEAR_Error"
["class"]=>
string(10) "PEAR_Error"
["object"]=>
object(PEAR_Error)#6 (8) {
["error_message_prefix"]=>
string(0) ""
["mode"]=>
int(1)
["level"]=>
int(1024)
["code"]=>
NULL
["message"]=>
string(2) ", "
["userinfo"]=>
NULL
["backtrace"]=>
array(3) {
[0]=>
array(7) {
["file"]=>
string(28) "/usr/share/pear/Net/IMAP.php"
["line"]=>
int(2112)
["function"]=>
string(10) "PEAR_Error"
["class"]=>
string(10) "PEAR_Error"
["object"]=>
*RECURSION*
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(2) ", "
}
}
[1]=>
array(7) {
["file"]=>
string(34) "/var/www/html/acltool/lib/IMAP.php"
["line"]=>
int(28)
["function"]=>
string(6) "getACL"
["class"]=>
string(8) "Net_IMAP"
["object"]=>
object(Net_IMAP)#3 (14) {
["supportedAuthMethods"]=>
array(3) {
[0]=>
string(10) "DIGEST-MD5"
[1]=>
string(8) "CRAM-MD5"
[2]=>
string(5) "LOGIN"
}
["supportedSASLAuthMethods"]=>
array(2) {
[0]=>
string(10) "DIGEST-MD5"
[1]=>
string(8) "CRAM-MD5"
}
["_serverAuthMethods"]=>
array(2) {
[0]=>
string(5) "PLAIN"
[1]=>
string(5) "PLAIN"
}
["currentMailbox"]=>
string(5) "INBOX"
["_socket"]=>
object(Net_Socket)#4 (13) {
["fp"]=>
resource(25) of type (stream)
["blocking"]=>
bool(true)
["persistent"]=>
bool(false)
["addr"]=>
string(12) "XXX.XXX.XXX.XXX"
["port"]=>
int(143)
["timeout"]=>
bool(false)
["lineLength"]=>
int(2048)
["_debug"]=>
bool(false)
["_default_error_mode"]=>
NULL
["_default_error_options"]=>
NULL
["_default_error_handler"]=>
string(0) ""
["_error_class"]=>
string(10) "PEAR_Error"
["_expected_errors"]=>
array(0) {
}
}
["_debug"]=>
bool(false)
["dbgDialog"]=>
string(0) ""
["_cmd_counter"]=>
int(8)
["_lastCmdID"]=>
string(5) "A0007"
["_unParsedReturn"]=>
bool(false)
["_connected"]=>
bool(true)
["_serverSupportedCapabilities"]=>
array(21) {
[0]=>
string(5) "IMAP4"
[1]=>
string(9) "IMAP4rev1"
[2]=>
string(3) "ACL"
[3]=>
string(5) "QUOTA"
[4]=>
string(8) "LITERAL+"
[5]=>
string(17) "MAILBOX-REFERRALS"
[6]=>
string(9) "NAMESPACE"
[7]=>
string(7) "UIDPLUS"
[8]=>
string(2) "ID"
[9]=>
string(16) "NO_ATOMIC_RENAME"
[10]=>
string(8) "UNSELECT"
[11]=>
string(8) "CHILDREN"
[12]=>
string(11) "MULTIAPPEND"
[13]=>
string(6) "BINARY"
[14]=>
string(4) "SORT"
[15]=>
string(21) "THREAD=ORDEREDSUBJECT"
[16]=>
string(17) "THREAD=REFERENCES"
[17]=>
string(12) "ANNOTATEMORE"
[18]=>
string(4) "IDLE"
[19]=>
string(10) "AUTH=PLAIN"
[20]=>
string(7) "SASL-IR"
}
["_useUTF_7"]=>
bool(true)
["lastline"]=>
string(20) "A0007 OK Completed
"
}
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(4) "mbox"
}
}
[2]=>
array(6) {
["file"]=>
string(30) "/tmp/acls.php"
["line"]=>
int(85)
["function"]=>
string(7) "getACLs"
["class"]=>
string(4) "IMAP"
["type"]=>
string(2) "::"
["args"]=>
array(1) {
[0]=>
&string(4) "mbox"
}
}
}
["callback"]=>
NULL
}
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(2) ", "
}
}
[1]=>
array(7) {
["file"]=>
string(34) "/tmp/IMAP.php"
["line"]=>
int(28)
["function"]=>
string(6) "getACL"
["class"]=>
string(8) "Net_IMAP"
["object"]=>
object(Net_IMAP)#3 (14) {
["supportedAuthMethods"]=>
array(3) {
[0]=>
string(10) "DIGEST-MD5"
[1]=>
string(8) "CRAM-MD5"
[2]=>
string(5) "LOGIN"
}
["supportedSASLAuthMethods"]=>
array(2) {
[0]=>
string(10) "DIGEST-MD5"
[1]=>
string(8) "CRAM-MD5"
}
["_serverAuthMethods"]=>
array(2) {
[0]=>
string(5) "PLAIN"
[1]=>
string(5) "PLAIN"
}
["currentMailbox"]=>
string(5) "INBOX"
["_socket"]=>
object(Net_Socket)#4 (13) {
["fp"]=>
resource(25) of type (stream)
["blocking"]=>
bool(true)
["persistent"]=>
bool(false)
["addr"]=>
string(12) "XXX.XXX.XXX.XXX"
["port"]=>
int(143)
["timeout"]=>
bool(false)
["lineLength"]=>
int(2048)
["_debug"]=>
bool(false)
["_default_error_mode"]=>
NULL
["_default_error_options"]=>
NULL
["_default_error_handler"]=>
string(0) ""
["_error_class"]=>
string(10) "PEAR_Error"
["_expected_errors"]=>
array(0) {
}
}
["_debug"]=>
bool(false)
["dbgDialog"]=>
string(0) ""
["_cmd_counter"]=>
int(8)
["_lastCmdID"]=>
string(5) "A0007"
["_unParsedReturn"]=>
bool(false)
["_connected"]=>
bool(true)
["_serverSupportedCapabilities"]=>
array(21) {
[0]=>
string(5) "IMAP4"
[1]=>
string(9) "IMAP4rev1"
[2]=>
string(3) "ACL"
[3]=>
string(5) "QUOTA"
[4]=>
string(8) "LITERAL+"
[5]=>
string(17) "MAILBOX-REFERRALS"
[6]=>
string(9) "NAMESPACE"
[7]=>
string(7) "UIDPLUS"
[8]=>
string(2) "ID"
[9]=>
string(16) "NO_ATOMIC_RENAME"
[10]=>
string(8) "UNSELECT"
[11]=>
string(8) "CHILDREN"
[12]=>
string(11) "MULTIAPPEND"
[13]=>
string(6) "BINARY"
[14]=>
string(4) "SORT"
[15]=>
string(21) "THREAD=ORDEREDSUBJECT"
[16]=>
string(17) "THREAD=REFERENCES"
[17]=>
string(12) "ANNOTATEMORE"
[18]=>
string(4) "IDLE"
[19]=>
string(10) "AUTH=PLAIN"
[20]=>
string(7) "SASL-IR"
}
["_useUTF_7"]=>
bool(true)
["lastline"]=>
string(20) "A0007 OK Completed
"
}
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(4) "mbox"
}
}
[2]=>
array(6) {
["file"]=>
string(30) "/tmp/acls.php"
["line"]=>
int(85)
["function"]=>
string(7) "getACLs"
["class"]=>
string(4) "IMAP"
["type"]=>
string(2) "::"
["args"]=>
array(1) {
[0]=>
&string(4) "mbox"
}
}
}
["callback"]=>
NULL
}
[2007-01-30 17:23 UTC] s dot e dot grier at qmul dot ac dot uk
Patch to fix this issue is:
--- IMAPProtocol.php.old 2007-01-30 14:48:36.000000000 +0000
+++ IMAPProtocol.php 2007-01-30 15:10:34.000000000 +0000
@@ -2918,6 +2918,10 @@
case "ACL" :
$this->_parseSpace( $str , __LINE__ , __FILE__ );
$this->_getNextToken( $str , $mailbox );
+ if (substr($str, 0, 2) == "\r\n") {
+ // No ACLs set on this mailbox.
+ return array("MAILBOX"=>$this->utf_7_decode($mailbox), "USERS"=>array());
+ }
$this->_parseSpace( $str , __LINE__ , __FILE__ );
$acl_arr = explode( ' ' , rtrim( substr( $this->_getToEOL( $str , false ) , 0 ) ) );
[2007-01-31 03:55 UTC] hudeldudel at php dot net
This bug has been fixed in CVS.
If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.
[2007-02-01 16:13 UTC] s dot e dot grier at qmul dot ac dot uk
I can confirm the fix works for me.
Thanks.