Skip to content

Honor mixed-case extended parameter names in format - #150

Closed
FFspiky wants to merge 1 commit into
jshttp:masterfrom
FFspiky:fix/mixed-case-extended-parameters
Closed

FFspiky wants to merge 1 commit into
jshttp:masterfrom
FFspiky:fix/mixed-case-extended-parameters

Conversation

@FFspiky

@FFspiky FFspiky commented Nov 17, 2026

Copy link
Copy Markdown

format() can emit two filename* parameters when a Unicode plain parameter and an explicit extended parameter differ in casing:

format({
  type: 'attachment',
  parameters: { Filename: '€ rates.pdf', 'filename*': "UTF-8''explicit.pdf" },
});
// Before: attachment; Filename*=UTF-8''%E2%82%AC%20rates.pdf; filename*=UTF-8''explicit.pdf
// After:  attachment; filename*=UTF-8''explicit.pdf

The duplicate is invalid under RFC 6266 §4.1, and filename parameter names are case-insensitive under §4.3. Parsing the old output also selects the synthesized filename instead of the explicit value.

Extend the precedence rule from #144 to compare parameter names case-insensitively. Build the normalized lookup only when extended encoding is needed, and retain the original output casing, Latin-1 fallback values, and multipart behavior.

This is separate from the inherited-property fix in #149: its current head still reproduces this mixed-case defect. Both changes apply together without conflict and their combined suite passes.

Validation:

  • Two new regression tests fail on unchanged master 2a79734; all 217 tests pass after the fix on macOS arm64 with Node 22.23.5 and 25.9.0.
  • npm test also runs formatting and TypeScript checks; coverage is 100% for statements, branches, functions, and lines. npm run build and git diff --check pass.
  • The unchanged Linux CI workflow passes at commit d21ebae for Node 22.23.4 and the workflow’s latest selection (27.0.0-alpha.0.1.1).
  • Temporarily applying fix(format): ignore inherited extended parameters #149 as well passes 218 tests; that PR’s changes are not included here.

Developed and validated with OpenAI Codex.

@FFspiky

FFspiky commented Nov 17, 2026

Copy link
Copy Markdown
Author

The upstream CI and CodeQL workflows are waiting for approval. Could you approve them when reviewing this PR? The unchanged fork CI workflow passed the full tests, formatting, and TypeScript checks at the exact PR commit d21ebae for both configured Node versions. The fork result does not include an upstream CodeQL run.

@blakeembrey

Copy link
Copy Markdown
Member

Opting to remove hiding any keys in #151 instead. Ideally it'd throw, but I think that's a worse breaking change here.

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.

2 participants