diff --git a/imap-core/lib/commands/list.js b/imap-core/lib/commands/list.js index cb1cd9db..45a8b053 100644 --- a/imap-core/lib/commands/list.js +++ b/imap-core/lib/commands/list.js @@ -133,12 +133,22 @@ module.exports = { }; - if (!mailbox) { + if (!mailbox && !filterSpecialUseFlags) { // return delimiter only - return listResponse(null, [{ - path: '/', - flags: '\\Noselect' - }]); + let response = { + tag: '*', + command: 'LIST', + attributes: [ + [{ + type: 'atom', + value: '\\Noselect' + }], '/', '/' + ] + }; + this.send(imapHandler.compiler(response)); + return callback(null, { + response: 'OK' + }); } // Do folder listing diff --git a/imap-core/test/protocol-test.js b/imap-core/test/protocol-test.js index 8b65c473..141b87ed 100644 --- a/imap-core/test/protocol-test.js +++ b/imap-core/test/protocol-test.js @@ -241,6 +241,26 @@ describe('IMAP Protocol integration tests', function () { }); describe('LIST', function () { + it('should list delimiter', function (done) { + let cmds = [ + 'T1 LOGIN testuser pass', + 'T2 LIST "" ""', + 'T3 LOGOUT' + ]; + + testClient({ + commands: cmds, + secure: true, + port + }, function (resp) { + resp = resp.toString(); + expect(resp.match(/^\* LIST /mg).length).to.equal(1); + expect(resp.indexOf('\r\n* LIST (\\Noselect) "/" "/"\r\n') >= 0).to.be.true; + expect(/^T2 OK/m.test(resp)).to.be.true; + done(); + }); + }); + it('should list all mailboxes', function (done) { let cmds = [ 'T1 LOGIN testuser pass',