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
This commit is contained in:
TheBitBrine 2025-10-26 04:39:02 +00:00 committed by Daniel Stenberg
parent 25aee8648a
commit e64c28e243
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 352 additions and 7 deletions

View file

@ -279,7 +279,7 @@ test3032 test3033 test3034 test3035 \
\
test3100 test3101 test3102 test3103 test3104 test3105 \
\
test3200 test3201 test3202 test3203 test3204 test3205 test3207 test3208 \
test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 \
test3209 test3210 test3211 test3212 test3213 test3214 test3215 \
test4000 test4001