nodemailer
Advanced tools
Comparing version 4.4.0 to 4.4.1
# CHANGELOG | ||
## 4.4.1 2017-12-08 | ||
- Better handling of unexpectedly dropping connections | ||
## 4.4.0 2017-11-10 | ||
@@ -4,0 +8,0 @@ |
@@ -13,3 +13,3 @@ 'use strict'; | ||
if (typeof buffer === 'string') { | ||
buffer = new Buffer(buffer, 'utf-8'); | ||
buffer = Buffer.from(buffer, 'utf-8'); | ||
} | ||
@@ -75,10 +75,8 @@ | ||
_transform(chunk, encoding, done) { | ||
let b64; | ||
if (encoding !== 'buffer') { | ||
chunk = new Buffer(chunk, encoding); | ||
chunk = Buffer.from(chunk, encoding); | ||
} | ||
if (!chunk || !chunk.length) { | ||
return done(); | ||
return setImmediate(done); | ||
} | ||
@@ -89,3 +87,3 @@ | ||
if (this._remainingBytes && this._remainingBytes.length) { | ||
chunk = Buffer.concat([this._remainingBytes, chunk]); | ||
chunk = Buffer.concat([this._remainingBytes, chunk], this._remainingBytes.length + chunk.length); | ||
this._remainingBytes = false; | ||
@@ -101,10 +99,18 @@ } | ||
b64 = this._curLine + encode(chunk); | ||
let b64 = this._curLine + encode(chunk); | ||
if (this.options.lineLength) { | ||
b64 = wrap(b64, this.options.lineLength); | ||
b64 = b64.replace(/(^|\n)([^\n]*)$/, (match, lineBreak, lastLine) => { | ||
this._curLine = lastLine; | ||
return lineBreak; | ||
}); | ||
// remove last line as it is still most probably incomplete | ||
let lastLF = b64.lastIndexOf('\n'); | ||
if (lastLF < 0) { | ||
this._curLine = b64; | ||
b64 = ''; | ||
} else if (lastLF === b64.length - 1) { | ||
this._curLine = ''; | ||
} else { | ||
this._curLine = b64.substr(lastLF + 1); | ||
b64 = b64.substr(0, lastLF + 1); | ||
} | ||
} | ||
@@ -114,6 +120,6 @@ | ||
this.outputBytes += b64.length; | ||
this.push(b64); | ||
this.push(Buffer.from(b64, 'ascii')); | ||
} | ||
done(); | ||
setImmediate(done); | ||
} | ||
@@ -120,0 +126,0 @@ |
@@ -109,3 +109,3 @@ 'use strict'; | ||
if (typeof chunk === 'string') { | ||
chunk = new Buffer(chunk, encoding); | ||
chunk = Buffer.from(chunk, encoding); | ||
} | ||
@@ -112,0 +112,0 @@ |
@@ -127,3 +127,3 @@ 'use strict'; | ||
if (typeof chunk === 'string') { | ||
chunk = new Buffer(chunk, encoding); | ||
chunk = Buffer.from(chunk, encoding); | ||
} | ||
@@ -130,0 +130,0 @@ |
@@ -61,3 +61,3 @@ 'use strict'; | ||
if (parsed.auth) { | ||
headers.Authorization = 'Basic ' + new Buffer(parsed.auth).toString('base64'); | ||
headers.Authorization = 'Basic ' + Buffer.from(parsed.auth).toString('base64'); | ||
} | ||
@@ -91,3 +91,3 @@ | ||
} else if (typeof options.body === 'object') { | ||
body = new Buffer( | ||
body = Buffer.from( | ||
Object.keys(options.body) | ||
@@ -101,3 +101,3 @@ .map(key => { | ||
} else { | ||
body = new Buffer(options.body.toString().trim()); | ||
body = Buffer.from(options.body.toString().trim()); | ||
} | ||
@@ -104,0 +104,0 @@ |
@@ -493,3 +493,3 @@ /* eslint no-undefined: 0 */ | ||
if (typeof element.content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) { | ||
element.content = new Buffer(element.content, encoding); | ||
element.content = Buffer.from(element.content, encoding); | ||
} | ||
@@ -519,3 +519,3 @@ | ||
element.content = /\bbase64$/i.test(parts[1]) ? new Buffer(parts[2], 'base64') : new Buffer(decodeURIComponent(parts[2])); | ||
element.content = /\bbase64$/i.test(parts[1]) ? Buffer.from(parts[2], 'base64') : Buffer.from(decodeURIComponent(parts[2])); | ||
@@ -522,0 +522,0 @@ if ('path' in element) { |
@@ -13,3 +13,3 @@ 'use strict'; | ||
if (typeof buffer === 'string') { | ||
buffer = new Buffer(buffer, 'utf-8'); | ||
buffer = Buffer.from(buffer, 'utf-8'); | ||
} | ||
@@ -176,3 +176,3 @@ | ||
if (encoding !== 'buffer') { | ||
chunk = new Buffer(chunk, encoding); | ||
chunk = Buffer.from(chunk, encoding); | ||
} | ||
@@ -179,0 +179,0 @@ |
@@ -34,3 +34,3 @@ 'use strict'; | ||
} | ||
this.push(new Buffer('\r\n')); | ||
this.push(Buffer.from('\r\n')); | ||
lastPos = i + 1; | ||
@@ -37,0 +37,0 @@ } |
@@ -216,5 +216,5 @@ /* eslint no-console: 0 */ | ||
if (!parts) { | ||
return callback(null, new Buffer(0)); | ||
return callback(null, Buffer.from(0)); | ||
} | ||
return callback(null, /\bbase64$/i.test(parts[1]) ? new Buffer(parts[2], 'base64') : new Buffer(decodeURIComponent(parts[2]))); | ||
return callback(null, /\bbase64$/i.test(parts[1]) ? Buffer.from(parts[2], 'base64') : Buffer.from(decodeURIComponent(parts[2]))); | ||
} else if (content.path) { | ||
@@ -226,3 +226,3 @@ return resolveStream(fs.createReadStream(content.path), callback); | ||
if (typeof data[key].content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) { | ||
content = new Buffer(data[key].content, encoding); | ||
content = Buffer.from(data[key].content, encoding); | ||
} | ||
@@ -229,0 +229,0 @@ |
@@ -40,3 +40,3 @@ 'use strict'; | ||
if (typeof chunk === 'string') { | ||
chunk = new Buffer(chunk); | ||
chunk = Buffer.from(chunk); | ||
} | ||
@@ -52,3 +52,3 @@ | ||
chunks.push(buf); | ||
chunks.push(new Buffer('.')); | ||
chunks.push(Buffer.from('.')); | ||
chunklen += buf.length + 1; | ||
@@ -67,3 +67,3 @@ lastPos = i + 1; | ||
} | ||
chunks.push(new Buffer('\r\n')); | ||
chunks.push(Buffer.from('\r\n')); | ||
lastPos = i + 1; | ||
@@ -99,7 +99,7 @@ } | ||
if (this.lastByte === 0x0a) { | ||
buf = new Buffer('.\r\n'); | ||
buf = Buffer.from('.\r\n'); | ||
} else if (this.lastByte === 0x0d) { | ||
buf = new Buffer('\n.\r\n'); | ||
buf = Buffer.from('\n.\r\n'); | ||
} else { | ||
buf = new Buffer('\r\n.\r\n'); | ||
buf = Buffer.from('\r\n.\r\n'); | ||
} | ||
@@ -106,0 +106,0 @@ this.outByteCount += buf.length; |
@@ -70,3 +70,3 @@ 'use strict'; | ||
if (proxy.auth) { | ||
reqHeaders['Proxy-Authorization'] = 'Basic ' + new Buffer(proxy.auth).toString('base64'); | ||
reqHeaders['Proxy-Authorization'] = 'Basic ' + Buffer.from(proxy.auth).toString('base64'); | ||
} | ||
@@ -105,3 +105,3 @@ | ||
if (remainder) { | ||
socket.unshift(new Buffer(remainder, 'binary')); | ||
socket.unshift(Buffer.from(remainder, 'binary')); | ||
} | ||
@@ -108,0 +108,0 @@ |
@@ -333,3 +333,3 @@ 'use strict'; | ||
if (this._authMethod !== 'XOAUTH2' && !this._auth.credentials) { | ||
if (this._authMethod !== 'XOAUTH2' && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) { | ||
if (this._auth.user && this._auth.pass) { | ||
@@ -361,3 +361,3 @@ this._auth.credentials = { | ||
'AUTH PLAIN ' + | ||
new Buffer( | ||
Buffer.from( | ||
//this._auth.user+'\u0000'+ | ||
@@ -780,3 +780,3 @@ '\u0000' + // skip authorization identity as it causes problems with some servers | ||
this._socket.write(new Buffer(str + '\r\n', 'utf-8')); | ||
this._socket.write(Buffer.from(str + '\r\n', 'utf-8')); | ||
} | ||
@@ -1204,3 +1204,3 @@ | ||
this._sendCommand(new Buffer(this._auth.credentials.user + '', 'utf-8').toString('base64')); | ||
this._sendCommand(Buffer.from(this._auth.credentials.user + '', 'utf-8').toString('base64')); | ||
} | ||
@@ -1228,3 +1228,3 @@ | ||
// Decode from base64 | ||
let base64decoded = new Buffer(challengeString, 'base64').toString('ascii'), | ||
let base64decoded = Buffer.from(challengeString, 'base64').toString('ascii'), | ||
hmac_md5 = crypto.createHmac('md5', this._auth.credentials.pass); | ||
@@ -1241,3 +1241,3 @@ | ||
this._sendCommand(new Buffer(prepended).toString('base64')); | ||
this._sendCommand(Buffer.from(prepended).toString('base64')); | ||
} | ||
@@ -1287,3 +1287,3 @@ | ||
this._sendCommand(new Buffer(this._auth.credentials.pass + '', 'utf-8').toString('base64')); | ||
this._sendCommand(Buffer.from(this._auth.credentials.pass + '', 'utf-8').toString('base64')); | ||
} | ||
@@ -1290,0 +1290,0 @@ |
@@ -181,3 +181,2 @@ 'use strict'; | ||
} | ||
returned = true; | ||
@@ -188,2 +187,3 @@ let timer = setTimeout(() => { | ||
} | ||
returned = true; | ||
// still have not returned, this means we have an unexpected connection close | ||
@@ -229,2 +229,3 @@ let err = new Error('Unexpected socket close'); | ||
connection.send(envelope, mail.message.createReadStream(), (err, info) => { | ||
returned = true; | ||
connection.close(); | ||
@@ -279,5 +280,5 @@ if (err) { | ||
} | ||
returned = true; | ||
if (err) { | ||
returned = true; | ||
connection.close(); | ||
@@ -284,0 +285,0 @@ return callback(err); |
@@ -226,3 +226,3 @@ 'use strict'; | ||
let authData = ['user=' + (this.options.user || ''), 'auth=Bearer ' + (accessToken || this.accessToken), '', '']; | ||
return new Buffer(authData.join('\x01'), 'utf-8').toString('base64'); | ||
return Buffer.from(authData.join('\x01'), 'utf-8').toString('base64'); | ||
} | ||
@@ -287,3 +287,3 @@ | ||
if (typeof data === 'string') { | ||
data = new Buffer(data); | ||
data = Buffer.from(data); | ||
} | ||
@@ -290,0 +290,0 @@ |
{ | ||
"name": "nodemailer", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"description": "Easy as cake e-mail sending from your Node.js applications", | ||
@@ -13,3 +13,5 @@ "main": "lib/nodemailer.js", | ||
}, | ||
"keywords": ["Nodemailer"], | ||
"keywords": [ | ||
"Nodemailer" | ||
], | ||
"author": "Andris Reinman", | ||
@@ -29,3 +31,3 @@ "license": "MIT", | ||
"grunt-mocha-test": "^0.13.3", | ||
"libbase64": "^0.2.0", | ||
"libbase64": "^1.0.1", | ||
"libmime": "^3.1.0", | ||
@@ -36,4 +38,4 @@ "libqp": "^1.1.0", | ||
"proxy-test-server": "^1.0.0", | ||
"sinon": "^4.1.2", | ||
"smtp-server": "^3.3.0" | ||
"sinon": "^4.1.3", | ||
"smtp-server": "^3.4.1" | ||
}, | ||
@@ -40,0 +42,0 @@ "engines": { |
@@ -11,6 +11,2 @@ # Nodemailer | ||
<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/riRUvXLoy7hDEa8ptqPY9cHd/nodemailer/nodemailer'> | ||
<img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/riRUvXLoy7hDEa8ptqPY9cHd/nodemailer/nodemailer.svg' /> | ||
</a> | ||
## Having an issue? | ||
@@ -17,0 +13,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
506822
10793
40