Skip to content

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

@andrinoff

Description

@andrinoff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions