Skip to content

Quote and encode IMAP mailbox names#108

Open
mpscholten wants to merge 1 commit into
qnikst:masterfrom
mpscholten:upstream/imap-mailbox-quoting
Open

Quote and encode IMAP mailbox names#108
mpscholten wants to merge 1 commit into
qnikst:masterfrom
mpscholten:upstream/imap-mailbox-quoting

Conversation

@mpscholten

Copy link
Copy Markdown
Contributor

Draft follow-up for IMAP mailbox handling. This is based directly on current upstream master and intentionally kept separate from #101.

Changes:

  • quote and escape mailbox names in public mailbox commands (SELECT, EXAMINE, CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, STATUS, APPEND, COPY, MOVE)
  • encode mailbox command arguments with IMAP modified UTF-7
  • decode modified UTF-7 mailbox names returned by LIST/LSUB
  • add focused parser/API tests and enable the imap-parsers test suite
  • update Source-Repository from git:// to https:// so current cabal check passes

Regression coverage:

  • command bytes for quoted mailbox names with spaces and quotes
  • command bytes for Entwürfe -> Entw&APw-rfe
  • command bytes for A&B -> A&-B
  • LIST decoding for Entw&APw-rfe and A&-B

Before wiring the fix, cabal test imap-parsers --test-show-details=direct failed on the new command-byte and LIST decoding tests.

Validation:

  • nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal test imap-parsers --test-show-details=direct
  • nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal build all
  • nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal check (only the existing CHANGELOG doc-place warning remains)
  • git diff --check

Note: this draft includes the same imap-parsers test-target setup and https:// repository metadata fix as #101 because it is independently based on upstream master. Once #101 merges, this branch can be rebased to drop that overlap.

@mpscholten mpscholten marked this pull request as ready for review June 5, 2026 14:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaa892f8bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

-> IO [(MailboxStatus, Integer)]
status conn mbox stats =
let cmd = "STATUS " ++ mbox ++ " (" ++ (unwords $ map show stats) ++ ")"
let cmd = "STATUS " ++ quoteMailboxName mbox ++ " (" ++ (unwords $ map show stats) ++ ")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse quoted STATUS mailbox names

When mbox contains a space, this now sends a valid quoted STATUS command, but conforming servers echo that mailbox as a string, e.g. * STATUS "foo bar" (...); pStatusLine still discards the name with anyChar manyTill space, so it stops inside the quoted name and then fails to parse the stats. In that scenario status conn "foo bar" ... throws a parse error instead of returning the status; the parser needs to consume an IMAP astring/quoted mailbox before the status list.

Useful? React with 👍 / 👎.

@mpscholten mpscholten force-pushed the upstream/imap-mailbox-quoting branch from cbfe450 to 0e242d9 Compare June 5, 2026 14:38
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.

1 participant