Home » Networking » Net_IMAP » Bug #9986
getMailboxes() breaks RFC3501/2060
Details
| Submitted | 2007-01-31 12:07 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 | linux 2.6.17 (FC5) |
| Roadmaps | (Not assigned) |
Comments
[2007-01-31 12:07 UTC] s dot e dot grier at qmul dot ac dot uk
Description:
------------
Function Net_IMAP::getMailboxes() breaks RFC3501/2060 when called with a second parameter of 1 (or boolean true).
The function description says a $restriction_search parameter of 1 will "return only the mailbox that contains that exact name". However, calling in this way results in an IMAP LIST command of the form:
. LIST "%" "mailbox"
This does not comply with RFC3501, which specifies the formal syntax of a LIST command as:
list = "LIST" SP mailbox SP list-mailbox
list-mailbox = 1*list-char / string
list-char = ATOM-CHAR / list-wildcards / resp-specials
list-wildcards = "%" / "*"
mailbox = "INBOX" / astring
So, wildcards are not permitted in the reference name parameter of the LIST command.
Note, this also does not achieve the stated result. Multiple mailboxes may be returned as a result of this LIST command. e.g:
. list "%" "bm"
* LIST (\HasChildren) "." "bm"
* LIST (\Noselect \HasChildren) "." "webmaster"
The correct way to do this in IMAP is:
. list "" "bm"
* LIST (\HasChildren) "." "bm"
. OK Completed (0.000 secs 3 calls)
Note, this bug is related to bug #7588 "mailboxExist() returns false positives". However, this issue was not fixed as a result of that item.
Test script:
---------------
<?php
require 'Net/IMAP.php';
$imap = new Net_IMAP('server', 'port');
$imap->login('user', 'XXXXXXX');
$mboxes = $imap->getMailboxes('bm', 1, true);
var_dump($mboxes);
$imap->disconnect();
?>
Expected result:
----------------
array(1) {
[0]=>
array(3) {
["MAILBOX"]=>
string(2) "bm"
["ATTRIBUTES"]=>
array(1) {
[0]=>
string(12) "\HasChildren"
}
["HIERACHY_DELIMITER"]=>
string(1) "."
}
}
Actual result:
--------------
array(2) {
[0]=>
array(3) {
["MAILBOX"]=>
string(2) "bm"
["ATTRIBUTES"]=>
array(1) {
[0]=>
string(12) "\HasChildren"
}
["HIERACHY_DELIMITER"]=>
string(1) "."
}
[1]=>
array(3) {
["MAILBOX"]=>
string(9) "webmaster"
["ATTRIBUTES"]=>
array(2) {
[0]=>
string(9) "\Noselect"
[1]=>
string(12) "\HasChildren"
}
["HIERACHY_DELIMITER"]=>
string(1) "."
}
}
[2007-01-31 12:09 UTC] s dot e dot grier at qmul dot ac dot uk
Patch to fix this issue is:
--- IMAP.php.1.11.cvs 2007-01-31 10:25:53.000000000 +0000
+++ IMAP.php 2007-01-31 12:07:43.000000000 +0000
@@ -1196,7 +1196,7 @@
break;
case 1:
$mailbox = $reference;
- $reference = '%';
+ $reference = '';
break;
case 2:
$mailbox = "%";
[2007-02-02 19:02 UTC] hudeldudel at php dot net
I've applied your patch. Please verify.
If you have some test cases for bug #7588, please report them there and reopen.
Thanks again for contributing!
hudeldudel
[2007-02-07 12:55 UTC] s dot e dot grier at qmul dot ac dot uk
I can confirm the latest CVS works for me. Thanks.