Fix FETCH response bugs: literal ordering and comma-separated sequence sets - #299
Open
maneesha-xyz wants to merge 4 commits into
Conversation
UID FETCH with multiple literal-bearing items (e.g. BODY.PEEK[1] BODY.PEEK[1.MIME]) currently returns all item names first, then all literals appended at the end, instead of each literal immediately following its own item name. Confirms issue #298 mechanically before the fix.
Literals were batched after all item names instead of following their own item, breaking strict IMAP clients on multi-item FETCH. Fixes #298
FETCH 1,3,5 currently returns BAD Invalid sequence number since the parser only understands a single number or an a:b range.
HandleFetch had its own inline sequence-set parser understanding only a single number or an a:b range, so any comma-separated set (1,3,5) or combination (1:3,7,9:*) fell through to strconv.Atoi and errored. Reuses utils.ParseSequenceSetWithDB, already used by STORE/COPY and already tested against comma syntax, instead of duplicating the logic.
maneesha-xyz
force-pushed
the
298-bug-fetch-response-merges-literals-for-multi-item-requests-breaks-strict-imap-clients-nextcloudhorde
branch
from
August 24, 2026 07:14
27847d9 to
8c0bd75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HEADER.FIELDSused=instead of+=on the shared literal buffer, silently dropping an earlier item's literal.FETCHnow accepts comma-separated sequence sets (1,3,5,1:3,7,9:*), previously rejected withBAD Invalid sequence number— was blocking folder loads in mail clients that batch-fetch this way. Reuses the already-testedutils.ParseSequenceSetWithDBinstead of duplicating parsing logic.Test plan
go test ./...green (excluding pre-existing, unrelated Docker-dependent e2e failures)FETCH 1,3,5via direct raw-socket test