npm / libmime
libmime
What changed in libmime 3 to 5, from its official release notes, upgrade guides and advisories. Also covers @types/libmime. Sources checked 2026-11-30.
2 breaking2 security3 new APIs and options2 performance1 tooling22 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initlibmime 531 changes
Breaking changes 1
All iconv-lite aliases of the utf-7, base64, and hex codecs are refused as charsets.
Security 2
Control characters are dropped from header values and parameter names.
Header parsing was hardened against prototype pollution and parser differentials.
New APIs and options 3
Adds a stream for decoding a body in any charset.
Adds the skipPrototypeKeys option to decodeHeaders().
Exposes normalizeCharset() on the public API.
Performance 2
Long non-ASCII words are encoded in linear time, improving encoding performance.
Flowed decoding and header unfolding now run in linear time.
Tooling 1
The project migrated to TypeScript and now provides ES module and CommonJS builds.
Fixes and other changes 22
Drops text following a closed quoted string up to the next parameter.
Continues the token of a parameter value when a parenthesis appears immediately after the equals sign.
The first value of a duplicated parameter is kept.
With stripComments enabled, comments are dropped from a MIME header value.
Resolves the x-mac charset labels and Big5-HKSCS.
Reads the byte order of UTF-16 from the BOM.
Decoding format=flowed now respects quote depth.
Parameter values that look like encoded words are now encoded.
Astral characters outside the emoji block are kept whole when encoded.
Continuation lines created by encodeFlowed are space-stuffed, and spaces before hard line breaks are trimmed.
Chunks of a Buffer passed to encodeWord are now base64-encoded only once.
Space stuffing is removed from format=flowed continuation lines.
Control characters and DEL are encoded in header parameter values.
Empty header parameter values are quoted.
Unpaired surrogates are encoded instead of leaving delimiters unencoded.
The pyc and ccxml entries are corrected, and common modern MIME types are added.
Every continuation holding percent escapes is marked as encoded.
Malformed input no longer causes splitMimeEncodedString to loop forever.
RFC 2231 parameters are marked as decoded.
Transfer-encoding codecs are refused when used as charsets.
B-encoded words are decoded through libbase64.
charset.decode returns a string for Japanese encodings.
libmime 31 changes
Breaking changes 1
Encoded-word generation now encodes from the first word with Unicode characters to the last, avoiding non-encoded parts between encoded words.