Skip to content

Commit

Permalink
fix(empty-listing): Treat empty LIST or LSUB response as an error con…
Browse files Browse the repository at this point in the history
…dition
  • Loading branch information
andris9 committed May 6, 2024
1 parent a4284c5 commit 53e3bc9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/imap-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,13 @@ class IMAPConnection extends BaseClient {
});

let listing = await connectionClient.list(options);
if (!listing.length) {
// server bug, the list can never be empty
this.imapClient.close();
let error = new Error('Server bug: empty mailbox listing');
error.code = 'ServerBug';
throw error;
}

let inboxData = (listing || []).find(entry => /^INBOX$/i.test(entry.path));
if (inboxData && inboxData.delimiter) {
Expand Down Expand Up @@ -466,7 +473,7 @@ class IMAPConnection extends BaseClient {
// on changes store updated listing
if (hasChanges) {
// store
let listingObject = {};
const listingObject = {};
listing.forEach(entry => {
let mailbox = {};
Object.keys(entry).forEach(key => {
Expand Down

0 comments on commit 53e3bc9

Please sign in to comment.