]> git.ipfire.org Git - thirdparty/curl.git/commit
imap: fix custom FETCH commands to handle literal responses
authorTheBitBrine <blacknomex08@gmail.com>
Sun, 26 Oct 2025 04:39:02 +0000 (04:39 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 30 Oct 2025 07:48:28 +0000 (08:48 +0100)
commite64c28e243d797da4ef76d6e89598f7fc2da8869
treedbcac035a5bcfe6f45fe6d51cb2be65a16f29ded
parent25aee8648ab1c8c5db03db0d3494523491511772
imap: fix custom FETCH commands to handle literal responses

Custom IMAP commands using -X (e.g. 'FETCH 123 BODY[1]') were only
returning the first line of responses containing literals, instead of
the full multi-line body data.

The issue was that custom commands route through imap_perform_list()
and imap_state_listsearch_resp(), which didn't detect or handle IMAP
literal syntax {size}.

This commit adds literal detection to imap_state_listsearch_resp():
- Detects literal syntax {size} in untagged responses
- Writes the response header line containing the literal marker
- Handles any literal body data already in the pingpong buffer
- Sets up transfer layer to read remaining literal data from socket
- Configures maxdownload and transfer size to include header + body
- Initializes pp->overflow to 0 when no buffered data present
- Modifies imap_done() to transition to FETCH_FINAL for custom
  commands that set up downloads

Test 841 and 3206 verify.

Fixes #18847
Reported-by: BohwaZ
Bug: https://github.com/curl/curl/issues/18847
Closes #19246
lib/imap.c
tests/data/Makefile.am
tests/data/test3206 [new file with mode: 0644]
tests/data/test841