matcha icon indicating copy to clipboard operation
matcha copied to clipboard

BUG: Unchecked error on quoted-printable writer Close()

Open andrinoff opened this issue 7 months ago • 1 comments

Describe the bug

In sender/sender.go line 220, quotedprintable.NewWriter().Close() error is ignored:

var encBody bytes.Buffer
qp := quotedprintable.NewWriter(&encBody)
fmt.Fprint(qp, plainBody)
qp.Close()  // Error ignored
encodedBody := encBody.Bytes()

If Close() fails (write errors, flush failures), encoded body may be incomplete/corrupted but code proceeds silently.

To reproduce

  1. Compose email with plain text body
  2. Simulate write error during quoted-printable encoding
  3. Close() fails but error not caught
  4. Corrupted email sent

Expected behavior

Check Close() error:

var encBody bytes.Buffer
qp := quotedprintable.NewWriter(&encBody)
if _, err := fmt.Fprint(qp, plainBody); err != nil {
    return err
}
if err := qp.Close(); err != nil {
    return fmt.Errorf("quoted-printable encoding failed: %w", err)
}
encodedBody := encBody.Bytes()

Screenshots

N/A

Additional context

  • File: sender/sender.go
  • Lines: 217-221
  • Severity: Medium - email body corruption
  • Fix complexity: Easy - add error check

andrinoff avatar Apr 16 '26 20:04 andrinoff

This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.

floatpanebot avatar May 17 '26 05:05 floatpanebot