Skip to content

fix: decode RFC 2047 words and add test coverage#8

Merged
gumruyanzh merged 1 commit into
mainfrom
fix/rfc2047-decoding-and-tests
Jul 5, 2026
Merged

fix: decode RFC 2047 words and add test coverage#8
gumruyanzh merged 1 commit into
mainfrom
fix/rfc2047-decoding-and-tests

Conversation

@gumruyanzh

Copy link
Copy Markdown
Contributor

Summary

Fixes a real display bug and establishes the repo's first test coverage.

  • RFC 2047 decoding (bug): imapclient.DialTLS(addr, nil) passed no WordDecoder, so encoded-word subjects and sender names (=?UTF-8?...?=, non-Latin scripts, emoji) rendered raw. Now passes a charset-aware decoder (UTF-8 + legacy charsets via go-message).
  • parser: share the charset-aware decoder via a helper; drop the string(body) round-trip in the fetch path for bytes.NewReader.
  • reply: case-insensitive Re: prefix check (was byte-compared, double-prefixed RE:/re:).
  • tests (new): parser_test.go (plain/HTML/multipart/attachment parse, compose→parse round-trip, RFC 2047 decode) and errors_test.go (error classification, exit codes, hints, unwrap). Repo previously had zero tests.
  • gofmt cleanup.

Verification

  • go build, go vet, gofmt -l clean; go test ./... green.
  • Live end-to-end smoke test against a real Yahoo account: auth login, folders list, mail list, mail read, mail search, star/unstar, and --json all pass. Emoji/curly-quote/encoded subjects now decode correctly on real data.

🤖 Generated with Claude Code

- imap: pass a charset-aware WordDecoder to DialTLS so encoded-word
  subjects and sender names (=?UTF-8?...?=, non-Latin scripts, emoji)
  decode instead of rendering raw. Passing nil left them mangled.
- parser: share the charset-aware decoder via a helper; replace the
  string round-trip in the fetch path with bytes.NewReader.
- mail reply: case-insensitive "Re:" prefix check (was byte-compared).
- tests: add unit coverage for the parser (parse plain/HTML/multipart/
  attachment, compose->parse round-trip, RFC 2047 decode) and for
  error classification/exit codes/hints. Repo previously had none.
- gofmt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gumruyanzh gumruyanzh merged commit 5a52ec3 into main Jul 5, 2026
1 check failed
@gumruyanzh gumruyanzh deleted the fix/rfc2047-decoding-and-tests branch July 5, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant