Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buildmail

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buildmail - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

4

CHANGELOG.md
# Changelog
## 3.3.0
* Added `prepared` option for the value argument of setheader/addHeader methods
## 3.2.0

@@ -4,0 +8,0 @@

@@ -455,7 +455,26 @@ 'use strict';

this._headers.forEach(function (header) {
var key = header.key,
value = header.value,
structured,
param;
var key = header.key;
var value = header.value;
var structured;
var param;
var options = {};
if (value && ['From', 'Sender', 'To', 'Cc', 'Bcc', 'Reply-To'].indexOf(key) < 0 && typeof value === 'object') {
Object.keys(value).forEach(function (key) {
if (key !== 'value') {
options[key] = value[key];
}
});
value = (value.value || '').toString();
if (!value.trim()) {
return;
}
}
if (options.prepared) {
// header value is
headers.push(key + ': ' + value);
return;
}
switch (header.key) {

@@ -500,4 +519,5 @@ case 'Content-Disposition':

value = _self._encodeHeaderValue(key, value);
// skip empty lines
value = _self._encodeHeaderValue(key, value);
if (!(value || '').toString().trim()) {

@@ -645,3 +665,2 @@ return;

outputStream.write(this.buildHeaders() + '\r\n\r\n');

@@ -648,0 +667,0 @@ setImmediate(sendContent);

2

package.json
{
"name": "buildmail",
"version": "3.2.0",
"version": "3.3.0",
"description": "buildmail is a low level rfc2822 message composer. Define your own mime tree, no magic included.",

@@ -5,0 +5,0 @@ "author": "Andris Reinman <andris@kreata.ee>",

@@ -231,2 +231,24 @@ # buildmail

## Prepared headers
Normally all headers are encoded and folded to meet the requirement of having plain-ASCII messages with lines no longer than 78 bytes. Sometimes it is preferable to not modify header values and pass these as provided. This can be achieved with the `prepared` option:
```javascript
new BuildMail('text/plain').
addHeader('X-Long-Header', {
prepared: true,
value: 'a really long header or value with non-ascii characters 👮'
});
// normal output:
// X-Long-Header: a really long header or value with non-ascii characters
// =?UTF-8?Q?=F0=9F=91=AE?=
// output with the prepared option:
// X-Long-Header: a really long header or value with non-ascii characters 👮
```
## getHeader

@@ -233,0 +255,0 @@

@@ -557,2 +557,3 @@ /* eslint no-unused-expressions:0 */

msg = msg.toString();
console.log(msg);
expect(/^From: the safewithme testuser <safewithme.testuser@xn\-\-jgeva-dua.com>$/m.test(msg)).to.be.true;

@@ -593,2 +594,51 @@ expect(/^Cc: the safewithme testuser <safewithme.testuser@xn\-\-jgeva-dua.com>$/m.test(msg)).to.be.true;

it('should not process prepared headers', function (done) {
var mb = new Buildmail('text/plain').
setHeader({
unprepared: {
value: new Array(100).join('a b')
},
prepared: {
value: new Array(100).join('a b'),
prepared: true
},
unicode: {
value: 'õäöü',
prepared: true
},
date: 'zzz',
'message-id': '67890'
}).
setContent('Hello world!'),
expected = 'Content-Type: text/plain\r\n' +
// long folded value
'Unprepared: a ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba\r\n' +
' ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba\r\n' +
' ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba\r\n' +
' ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba\r\n' +
' ba ba ba b\r\n' +
// long unfolded value
'Prepared: a ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba b\r\n' +
// non-ascii value
'Unicode: õäöü\r\n' +
'Date: zzz\r\n' +
'Message-Id: <67890>\r\n' +
'Content-Transfer-Encoding: 7bit\r\n' +
'MIME-Version: 1.0\r\n' +
'\r\n' +
'Hello world!';
mb.build(function (err, msg) {
expect(err).to.not.exist;
msg = msg.toString();
expect(msg).to.equal(expected);
done();
});
});
it('should set default transfer encoding for application content', function (done) {

@@ -595,0 +645,0 @@ var mb = new Buildmail('application/x-my-stuff').

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc