Skip to content

Commit 7e02648

Browse files
committed
v6.6.1
1 parent 1750c0f commit 7e02648

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ node_js:
44
- 10
55
- 12
66
- 14
7-
- 15
7+
- 16
88
notifications:
99
email:
1010
- andris@kreata.ee

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 6.6.1 2021-05-23
4+
5+
- Fixed address formatting issue where newlines in an email address, if provided via address object, were not properly removed. Reported by tmazeika (#1289)
6+
37
## 6.6.0 2021-04-28
48

59
- Added new option `newline` for MailComposer

Diff for: examples/mailcomposer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const mailOptions = {
99
from: 'Daemon <deamon@kreata.ee>',
1010
to: 'mailer@kreata.ee, Mailer <mailer2@kreata.ee>'
1111
},
12-
text: 'Test\n 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ö\r\nsage',
12+
text: `Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversations?'
13+
14+
So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.`,
1315
newline: '\r\n'
1416
};
1517

Diff for: lib/mime-node/index.js

+27-7
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,9 @@ class MimeNode {
11471147
address.address = this._normalizeAddress(address.address);
11481148

11491149
if (!address.name) {
1150-
values.push(address.address);
1150+
values.push(address.address.indexOf(' ') >= 0 ? `<${address.address}>` : `${address.address}`);
11511151
} else if (address.name) {
1152-
values.push(this._encodeAddressName(address.name) + ' <' + address.address + '>');
1152+
values.push(`${this._encodeAddressName(address.name)} <${address.address}>`);
11531153
}
11541154

11551155
if (address.address) {
@@ -1158,9 +1158,8 @@ class MimeNode {
11581158
}
11591159
}
11601160
} else if (address.group) {
1161-
values.push(
1162-
this._encodeAddressName(address.name) + ':' + (address.group.length ? this._convertAddresses(address.group, uniqueList) : '').trim() + ';'
1163-
);
1161+
let groupListAddresses = (address.group.length ? this._convertAddresses(address.group, uniqueList) : '').trim();
1162+
values.push(`${this._encodeAddressName(address.name)}:${groupListAddresses};`);
11641163
}
11651164
});
11661165

@@ -1174,13 +1173,17 @@ class MimeNode {
11741173
* @return {String} address string
11751174
*/
11761175
_normalizeAddress(address) {
1177-
address = (address || '').toString().trim();
1176+
address = (address || '')
1177+
.toString()
1178+
.replace(/[\x00-\x1F<>]+/g, ' ') // remove unallowed characters
1179+
.trim();
11781180

11791181
let lastAt = address.lastIndexOf('@');
11801182
if (lastAt < 0) {
11811183
// Bare username
11821184
return address;
11831185
}
1186+
11841187
let user = address.substr(0, lastAt);
11851188
let domain = address.substr(lastAt + 1);
11861189

@@ -1189,7 +1192,24 @@ class MimeNode {
11891192
// 'jõgeva.ee' will be converted to 'xn--jgeva-dua.ee'
11901193
// non-unicode domains are left as is
11911194

1192-
return user + '@' + punycode.toASCII(domain.toLowerCase());
1195+
let encodedDomain;
1196+
1197+
try {
1198+
encodedDomain = punycode.toASCII(domain.toLowerCase());
1199+
} catch (err) {
1200+
// keep as is?
1201+
}
1202+
1203+
if (user.indexOf(' ') >= 0) {
1204+
if (user.charAt(0) !== '"') {
1205+
user = '"' + user;
1206+
}
1207+
if (user.substr(-1) !== '"') {
1208+
user = user + '"';
1209+
}
1210+
}
1211+
1212+
return `${user}@${encodedDomain}`;
11931213
}
11941214

11951215
/**

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodemailer",
3-
"version": "6.6.0",
3+
"version": "6.6.1",
44
"description": "Easy as cake e-mail sending from your Node.js applications",
55
"main": "lib/nodemailer.js",
66
"scripts": {
@@ -31,7 +31,7 @@
3131
"libbase64": "1.2.1",
3232
"libmime": "5.0.0",
3333
"libqp": "1.1.0",
34-
"mocha": "8.3.2",
34+
"mocha": "8.4.0",
3535
"nodemailer-ntlm-auth": "1.0.1",
3636
"proxy": "1.0.2",
3737
"proxy-test-server": "1.0.0",

0 commit comments

Comments
 (0)