fix: decode RFC 2047 words and add test coverage#8
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a real display bug and establishes the repo's first test coverage.
imapclient.DialTLS(addr, nil)passed noWordDecoder, 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).string(body)round-trip in the fetch path forbytes.NewReader.Re:prefix check (was byte-compared, double-prefixedRE:/re:).parser_test.go(plain/HTML/multipart/attachment parse, compose→parse round-trip, RFC 2047 decode) anderrors_test.go(error classification, exit codes, hints, unwrap). Repo previously had zero tests.Verification
go build,go vet,gofmt -lclean;go test ./...green.auth login,folders list,mail list,mail read,mail search,star/unstar, and--jsonall pass. Emoji/curly-quote/encoded subjects now decode correctly on real data.🤖 Generated with Claude Code