Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
mimelib is a collection of useful functions to deal with mime-encoded data.
Install with npm
npm install mimelib
var mimelib = require("mimelib");
mimelib.contentTypes
is an object to provide content type strings for common
file extensions
mimelib.contentTypes["xls"]; // "application/vnd.ms-excel"
Folds a long line according to the RFC 5322 http://tools.ietf.org/html/rfc5322#section-2.1.1
mimelib.foldLine(str [, maxLength][, foldAnywhere]) -> String
str
(String): mime string that might need foldingmaxLength
(Number): max length for a line, defaults to 78foldAnywhere
(Boolean): can fold at any location (ie. in base64)afterSpace
(Boolean): If true
fold after the spaceFor example:
Content-Type: multipart/alternative; boundary="----zzzz----"
will become
Content-Type: multipart/alternative;
boundary="----zzzz----"
Encodes a string into mime encoded word format http://en.wikipedia.org/wiki/MIME#Encoded-Word (see also decodeMimeWord
)
mimelib.encodeMimeWord = function(str [, encoding][, charset])
str
(String): String to be encodedencoding
(String): Encoding Q for quoted printable or B (def.) for base64charset
(String): Charset to be usedFor example:
See on õhin test
Becomes with UTF-8 and Quoted-printable encoding
=?UTF-8?q?See_on_=C3=B5hin_test?=
Decodes a string from mime encoded word format (see also encodeMimeWord
)
mimelib.decodeMimeWord(str) -> String
str
(String): String to be decodedFor example
mimelib.decodeMimeWord("=?UTF-8?q?See_on_=C3=B5hin_test?=");
will become
See on õhin test
Encodes a string into Quoted-printable format (see also decodeQuotedPrintable
)
mimelib.encodeQuotedPrintable(str [, mimeWord][, charset]) -> String
str
(String): String to be encoded into Quoted-printablemimeWord
(Boolean): Use mime-word mode (defaults to false)charset
(String): Destination charset, defaults to UTF-8Decodes a string from Quoted-printable format (see also encodeQuotedPrintable
)
mimelib.deccodeQuotedPrintable(str [, mimeWord][, charset]) -> String
str
(String): String to be decodedmimeWord
(Boolean): Use mime-word mode (defaults to false)charset
(String): Charset to be used, defaults to UTF-8Encodes a string into Base64 format. Base64 is mime-word safe (see also decodeBase64
)
mimelib.encodeBase64(str [, charset]) -> String
str
(String): String to be encoded into Base64charset
(String): Destination charset, defaults to UTF-8Decodes a string from Base64 format. Base64 is mime-word safe (see also encodeBase64
)
NB! Always returns UTF-8
mimelib.decodeBase64(str) -> String
str
(String): String to be decoded from Base64charset
(String): Source charset, defaults to UTF-8Parses header lines into an array of objects (see parseHeaderLine
)
mimelib.parseHeaders(headers) -> Array
headers
(String): header section of the e-mailExample:
var headers = [
"From: andris@node.ee",
"To: juulius@node.ee",
"To: juulius2@node.ee",
"Content-type: text/html;",
" charset=utf-8"
].join("\r\n");
mimelib.parseHeaders(headers);
Results in
{"from": [ 'andris@node.ee' ],
"to": [ 'juulius@node.ee', 'juulius2@node.ee' ],
"content-type": [ 'text/html; charset=utf-8' ] }
Parses names and addresses from a from, to, cc or bcc line
mimelib.parseAddresses(addresses) -> Array
addresses
(String): string with comma separated e-mail addressesExample:
var to = '"Andris Reinman" <andris@node.ee>, juulius@node.ee'
mimelib.parseAddresses(to);
Results in
[{ address: 'andris@node.ee', name: 'Andris Reinman' },
{ address: 'juulius@node.ee', name: false }]
Parses mime-words into UTF-8 strings
mimelib.parseMimeWords(str) -> String
str
(String): string to be parsed, if includes any mime words, then these are converted to UTF-8 strings
For example:
mimelib.parseMimeWords("Hello: =?UTF-8?q?See_on_=C3=B5hin_test?=");
Results in
"Hello: See on õhin test"
Parses a header line to search for additional parameters.
mimelib.parseHeaderLine(line) -> Object
line
(String): a line from a message headersFor example:
mimelib.parseHeaderLine("text/plain; charset=utf-8")imelib
Results in
{"defaultValue": 'text/plain',
"charset": 'utf-8' }
FAQs
MIME functions to encode/decode e-mails etc.
The npm package mimelib receives a total of 76,869 weekly downloads. As such, mimelib popularity was classified as popular.
We found that mimelib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.