Repository navigation
test(mail): cover decodeCharset and headerParams by name (#221) - #247
Merged
juancguerrerodev merged 5 commits intoDec 6, 2026
Merged
Conversation
10 of 16 tasks
Contributor
|
Ready to merge once the pull request template is filled in, including the "I read and ran everything" box (details on #234). 🦀 |
juancguerrerodev
force-pushed
the
test/mail-charset-221
branch
from
December 6, 2026 07:57
fe5c809 to
616a0b5
Compare
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.
Closes #221
packages/mail/src/mime-read.tsreads incoming mail from IMAP. Two of its helpers had no test that called them byname:
decodeCharset, which turns a part's bytes into text for its declared charset, andheaderParams, which splitsa
Content-TypeorContent-Dispositioninto its value and parameters. The existing tests reached them only throughwhole messages.
What this PR does
describeblock for each helper topackages/mail/test/mime-read.test.ts, importing them from../src/mime-read.ts. Tests only:mime-read.tsis unchanged.Tests
decodeCharsetwithutf-8andUTF8(any case, with spaces around it) decodes UTF-8: "señal", "acción" and anemoji.
iso-8859-1,latin1andwindows-1252, a byte like0xF1reads as "ñ", and bytes in0x80to0x9Freadas Windows-1252 (for example
0x80is the euro sign and0x93and0x94are curly quotes).with no U+FFFD in the result.
headerParams("text/plain; charset=UTF-8")gives the valuetext/plainand the parametercharset.;inside quotes does not split, and a backslash escape inside quotes keeps the next character.=is skipped.undefinedgives an empty value and noparameters.
makes on purpose.
How to check
Keep in mind
Uint8Array.from([...])orTextEncoder. Made-up text only, never a real message.Pull request template
What and why
Closes #221.
Adds named tests for decodeCharset and headerParams in the IMAP reader.
Vision fit
Principle 5, Spanish and English first-class: much of Latin America's mail still arrives as Windows-1252, and it now reads as intended by test.
Non-negotiables
Checklist
acceptedproposal.pnpm check:privacy,pnpm typecheck,pnpm lint,pnpm testandnode scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. Gate note: privacy and guard pass on this checkout today; the rest was run per package as listed under AI agents, not as one root gate on this Windows machine, where unrelated pre-existing failures appear in the site badges, the devices table and mobile source scans.packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.Model path
packages/model,agent,skillsoreval, the prompt, the router, tool descriptions, normalizers, examples or the model file.Screenshots
New dependencies and network calls
None. No new dependency and no new network call.
AI agents
What was run: pnpm --filter @hermit/mail exec vitest run test/mime-read.test.ts (16/16); full @hermit/mail test at the time; typecheck; eslint.