1
0
Fork 0
mirror of https://git.sr.ht/~rjarry/aerc synced 2026-02-20 15:05:22 +01:00
aerc/commands/compose
Robin Jarry fc39ea68ae send: fix empty message copied to sent folder
Since commit 64a2dd30ba ("compose: validate message before starting
SMTP transaction"), the message is first written into a bytes.Buffer
before being sent. The buffer contents are then sent via io.Copy to the
SMTP sender and subsequently copied again to the copy-to-folder buffer.

However, bytes.Buffer is a stream: io.Copy drains it entirely when
sending to SMTP. The second io.Copy then reads from an already-empty
buffer, resulting in an empty message being appended to the sent folder.

Use msgBuf.Bytes() to populate the copy buffer before draining it into
the SMTP sender. bytes.Buffer.Bytes() returns the unread data as a slice
without consuming it, so the buffer remains intact for the subsequent
io.Copy.

Fixes: 64a2dd30ba ("compose: validate message before starting SMTP transaction")
Reported-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2026-02-10 22:52:05 +01:00
..
abort.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
attach-key.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
attach.go config: allow specifying the temporary directory 2025-10-30 21:17:44 +01:00
cc-bcc.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
detach.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
edit.go reload: fix crash when reloading via IPC 2025-09-23 14:02:37 +02:00
encrypt.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
header.go commands: quote and add space to completions by default 2025-11-17 09:51:00 +01:00
multipart.go reload: fix crash when reloading via IPC 2025-09-23 14:02:37 +02:00
next-field.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
postpone.go messages: generalize cancellation context 2026-02-09 14:46:27 +01:00
send.go send: fix empty message copied to sent folder 2026-02-10 22:52:05 +01:00
sign.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00
switch.go compose: differentiate between edit and review commands 2025-01-14 15:00:56 +01:00