Repository navigation
fix(smime): never break the header block when folding In-Reply-To/References - #31
Merged
Merged
Conversation
Header values from the host can carry CR/LF; folding them produced empty lines inside References, which ended the header block so recipients saw the raw MIME source. Fold at whitespace only, normalise message ids to <id>, split RFC 2047 words on character boundaries, encode non-ASCII display names, use the sender's domain for Message-ID and keep the identity's display name in From. Fixes #6 Fixes #7
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
Signed replies built by the S/MIME plugin can arrive as raw source at the recipient.
formatHeaderinsmime/src/mime-builder.jsfolds at 76 characters and takesIn-Reply-To/Referencesfrom the host as-is. When those values carry CR/LF (seen when replying to a message that was itself sent through the plugin), folding can produce empty or whitespace-only lines insideReferences. An empty line ends the header block, soMIME-Version/Content-Typeand everything after it become body text.The same code path also writes message ids without angle brackets (the host passes bare ids), splits long ids (Outlook's
...@....PROD.OUTLOOK.COM) in the middle, folds long non-ASCII subjects inside an RFC 2047 encoded-word (#7), writes non-ASCII display names as raw 8-bit (#6), generates Message-IDs with@smime.local, and puts only the address intoFrombecauseonComposeSendignoresfromName.Changes
In-Reply-To/Referencesto<id>lists (strip existing brackets, split on whitespace).smime.local.smime/src/index.js: takefromNamefrom the compose request intoFromwhen the address carries no name.smime/test/mime-builder.test.mjs.Related issues
Fixes #6
Fixes #7
Related to #19 (signed attributes for Outlook). Independent of this change; we also run it and recommend merging.
Type of change
Checklist
npm run typecheck && npm run lintand there are no errors (this repo has notypecheckorlintscript; rannpm run checkinstead: ok)node scripts/build-isolated.mjs smime)locales/) if my changes affect user-facing text (n/a, no user-facing text)Screenshots / demo
n/a
Notes for reviewers
Testing:
smime/test/mime-builder.test.mjswith 6 cases: 5 fail onmain, all pass with this change. TheFromdisplay-name case passes on both, since thefromNamechange lives inindex.js.npx vitest run smime: 106 passed (100 onmain).npm test: 1293 passed, 1 skipped.On the wire, non-ASCII subjects and display names become encoded-words,
In-Reply-To/Referencescarry<id>brackets and the generatedMessage-IDuses the sender's domain. Runs of whitespace in subjects and display names collapse to one space, and tokens without@are dropped fromIn-Reply-To/References. Attachment filename parameters keep the oldencodeHeaderValueon purpose, so nothing changes there.smime/manifest.jsonandsmime.zipare untouched; the release is left to you.npm run build:checkreportssmime.zipas stale, which it already does onmain.Found during penetration test by turingpoint.