Skip to content

fix(imap): parse STATUS responses with an unquoted mailbox name - #290

Merged
robert-virkus merged 2 commits into
Enough-Software:mainfrom
hobleyd:fix/imap-status-unquoted-mailbox
Sep 26, 2026
Merged

robert-virkus merged 2 commits into
Enough-Software:mainfrom
hobleyd:fix/imap-status-unquoted-mailbox

Conversation

@hobleyd

@hobleyd hobleyd commented Sep 22, 2026

Copy link
Copy Markdown

Problem

StatusParser required the mailbox name to be double-quoted: RegExp(r'(STATUS "[^"]+?" )(.*)'). RFC 3501 allows the mailbox to be sent as an atom, and Dovecot does so (* STATUS INBOX (MESSAGES 231 UNSEEN 5 ...)), so the regex never matched and messagesExists/messagesUnseen/uidNext were silently left at 0 for every mailbox on such a server.

Fix

The regex accepts either a quoted string or an atom: (STATUS (?:"[^"]+?"|[^ (]+) )(.*). The existing test for a quoted name containing brackets still passes.

Tests

New test in status_parser_test.dart for STATUS INBOX (MESSAGES 231 UNSEEN 5 UIDNEXT 4392). Fails against main.

djhobley and others added 2 commits September 23, 2026 08:36
StatusParser required the mailbox name to be double-quoted
(`STATUS "INBOX" (...)`). RFC 3501 allows the name to be sent as an atom,
and Dovecot does so (`STATUS INBOX (...)`), so the regex never matched
and MESSAGES/UNSEEN/UIDNEXT were silently left at 0 for every mailbox.

The regex now accepts either a quoted string or an atom.
@robert-virkus
robert-virkus merged commit 5697e12 into Enough-Software:main Sep 26, 2026
1 check failed
@robert-virkus

Copy link
Copy Markdown
Member

<3

@christhomas

Copy link
Copy Markdown

Hi, just wanted to ping you here because this fix has no released version, can we do that?

@hobleyd

hobleyd commented Oct 19, 2026 •

Copy link
Copy Markdown
Author

Hi, just wanted to ping you here because this fix has no released version, can we do that?

I use a dependency override in the pubspec.yaml while waiting for the release. Check it out locally and use:

dependency_overrides:
  # Locally patched copy of enough_mail 2.1.7. Every patch has been raised
  # against Enough-Software/enough_mail; drop this override once all of these
  # have merged and shipped in a release:
  #   #287 quoted-printable attachments decoded to bytes
  #   #288 pending IMAP commands fail when the connection is lost
  #   #289 mailbox names containing parentheses (LIST parser + quoting)
  #   #290 STATUS with an unquoted mailbox name (Dovecot)
  #   #291 STATUS records HIGHESTMODSEQ
  #   #292 APPEND internalDate + appendMessageBytes (stacked on #289)
  #   #293 bare-LF line endings in a fetched BODY[] literal
  #   #294 SMTP DATA kept the folded continuation lines of a long Bcc header
  enough_mail:
    path: packages/enough_mail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants