Skip to content

Commit b7d18da

Browse files
authored
Release v2.2.3 (#73)
- dep(eslint): upgrade to v9 - when condensing whitespace, use global regex - avoid a polynomial regex on uncontrolled data
1 parent 024ef1e commit b7d18da

File tree

9 files changed

+65
-38
lines changed

9 files changed

+65
-38
lines changed

.codeclimate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
engines:
22
eslint:
33
enabled: true
4-
channel: 'eslint-8'
4+
channel: 'eslint-9'
55
config:
6-
config: '.eslintrc.yaml'
6+
config: 'eslint.config.mjs'
77

88
ratings:
99
paths:

.eslintrc.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.release

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
44

55
### Unreleased
66

7+
### [2.2.3] - 2025-01-13
8+
9+
- dep(eslint): upgrade to v9
10+
711
### [2.2.2] - 2024-04-29
812

913
- doc(CONTRIBUTORS): added
@@ -87,3 +91,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
8791
[2.0.6]: https://github.com/haraka/node-address-rfc2822/releases/tag/2.0.6
8892
[0.0.2]: https://github.com/haraka/node-address-rfc2822/releases/tag/v0.0.2
8993
[2.2.2]: https://github.com/haraka/node-address-rfc2822/releases/tag/v2.2.2
94+
[2.2.3]: https://github.com/haraka/node-address-rfc2822/releases/tag/v2.2.3

CONTRIBUTORS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
This handcrafted artisinal software is brought to you by:
44

5-
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=msimerson">39</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/662371?v=4"><br><a href="https://github.com/baudehlo">baudehlo</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=baudehlo">13</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/3326440?v=4"><br><a href="https://github.com/osm">osm</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=osm">2</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/26602940?v=4"><br><a href="https://github.com/0xflotus">0xflotus</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=0xflotus">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/362368?v=4"><br><a href="https://github.com/diasbruno">diasbruno</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=diasbruno">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/3902676?v=4"><br><a href="https://github.com/kesselb">kesselb</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=kesselb">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/260837?v=4"><br><a href="https://github.com/fionawhim">fionawhim</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=fionawhim">1</a>) |
5+
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=msimerson">40</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/662371?v=4"><br><a href="https://github.com/baudehlo">baudehlo</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=baudehlo">13</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/3326440?v=4"><br><a href="https://github.com/osm">osm</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=osm">2</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/26602940?v=4"><br><a href="https://github.com/0xflotus">0xflotus</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=0xflotus">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/362368?v=4"><br><a href="https://github.com/diasbruno">diasbruno</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=diasbruno">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/3902676?v=4"><br><a href="https://github.com/kesselb">kesselb</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=kesselb">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/260837?v=4"><br><a href="https://github.com/fionawhim">fionawhim</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=fionawhim">1</a>) |
66
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
77
| <img height="80" src="https://avatars.githubusercontent.com/u/25829?v=4"><br><a href="https://github.com/markstos">markstos</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=markstos">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/1705228?v=4"><br><a href="https://github.com/dwali">dwali</a> (<a href="https://github.com/haraka/node-address-rfc2822/commits?author=dwali">1</a>) |
88

9-
<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
9+
<sub>this file is generated by [.release](https://github.com/msimerson/.release).
10+
Contribute to this project to get your GitHub profile included here.</sub>

eslint.config.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import globals from 'globals'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import js from '@eslint/js'
5+
import { FlatCompat } from '@eslint/eslintrc'
6+
7+
const __filename = fileURLToPath(import.meta.url)
8+
const __dirname = path.dirname(__filename)
9+
const compat = new FlatCompat({
10+
baseDirectory: __dirname,
11+
recommendedConfig: js.configs.recommended,
12+
allConfig: js.configs.all,
13+
})
14+
15+
export default [
16+
...compat.extends('@haraka'),
17+
{
18+
languageOptions: {
19+
globals: {
20+
...globals.node,
21+
...globals.mocha,
22+
},
23+
},
24+
},
25+
]

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ exports.parse = function parse(line, opts = null) {
4040
commaInDisplayName: allowCommaInDisplayName,
4141
})
4242

43-
if (!addr) throw new Error('No results')
44-
45-
// console.log("Parsed to: ", require('util').inspect(addr, {depth: 10, colors: true}));
43+
if (!addr || addr.length === 0) throw new Error('No results')
4644

4745
return addr.addresses.map(map_addresses)
4846
}
@@ -93,8 +91,7 @@ class Group {
9391

9492
if (!(phrase && phrase.length)) phrase = this.comment
9593

96-
const name = _extract_name(phrase)
97-
return name
94+
return _extract_name(phrase)
9895
}
9996
}
10097

@@ -233,7 +230,7 @@ function _extract_name(name) {
233230
if (/=?.*?\?=/.test(name)) return ''
234231

235232
// trim & condense whitespace
236-
name = name.trim().replace(/\s+/, ' ')
233+
name = name.trim().replace(/\s+/g, ' ')
237234

238235
// Disregard numeric names (e.g. 123456.1234@compuserve.com)
239236
if (/^[\d ]+$/.test(name)) return ''
@@ -247,7 +244,7 @@ function _extract_name(name) {
247244
name = name.slice(1, name.length - 1)
248245

249246
name = name
250-
.replace(/\(.*?\)/g, '') // remove minimal embedded comments
247+
.replace(/\([^)]*\)/g, '') // remove minimal embedded comments
251248
.replace(/\\/g, '') // remove all escapes
252249

253250
// remove internal quotation marks

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "address-rfc2822",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "RFC 2822 & 5322 (Header) email address parser",
55
"main": "index.js",
66
"files": [
@@ -18,8 +18,8 @@
1818
],
1919
"scripts": {
2020
"format": "npm run prettier:fix && npm run lint:fix",
21-
"lint": "npx eslint@^8 *.js test",
22-
"lint:fix": "npx eslint@^8 *.js test --fix",
21+
"lint": "npx eslint *.js test",
22+
"lint:fix": "npx eslint *.js test --fix",
2323
"prettier": "npx prettier . --check",
2424
"prettier:fix": "npx prettier . --write --log-level=warn",
2525
"test": "npx mocha@10",
@@ -31,7 +31,7 @@
3131
"url": "https://github.com/haraka/node-address-rfc2822.git"
3232
},
3333
"devDependencies": {
34-
"@haraka/eslint-config": "1.1.5"
34+
"@haraka/eslint-config": "2.0.2"
3535
},
3636
"license": "MIT",
3737
"dependencies": {

test/functions.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,43 +40,44 @@ describe('nameCase', function () {
4040
})
4141

4242
describe('parseFrom', function () {
43-
it('Travis CI <builds@travis-ci.org>', function (done) {
43+
it('Travis CI <builds@travis-ci.org>', function () {
4444
try {
4545
const r = address.parseFrom('Travis CI <builds@travis-ci.org>')
46-
assert.equal(r[0].address, 'builds@travis-ci.org')
47-
// console.log(r);
46+
assert.deepEqual(r[0], {
47+
phrase: 'Travis CI',
48+
comment: '',
49+
address: 'builds@travis-ci.org',
50+
})
4851
} catch (e) {
4952
console.error(e)
5053
}
51-
done()
5254
})
53-
it('root (Cron Daemon)', function (done) {
55+
56+
it('root (Cron Daemon)', function () {
5457
try {
5558
const r = address.parseFrom('root (Cron Daemon)')
56-
assert.equal(r[0].address, '')
57-
// console.log(r);
59+
assert.deepEqual(r[0], { address: '' })
5860
} catch (e) {
5961
assert.equal(e.message, 'No results')
6062
}
61-
done()
6263
})
6364
})
6465

6566
describe('parseSender', function () {
66-
it('"Anne Standley, PMPM" <info=protectmypublicmedia.org@mail172.atl101.mcdlv.net>', function (done) {
67+
it('"Anne Standley, PMPM" <info=protectmypublicmedia.org@mail172.atl101.mcdlv.net>', function () {
6768
try {
6869
const r = address.parseSender(
6970
'"Anne Standley, PMPM" <info=protectmypublicmedia.org@mail172.atl101.mcdlv.net>',
7071
)
71-
assert.equal(
72-
r[0].address,
73-
'info=protectmypublicmedia.org@mail172.atl101.mcdlv.net',
74-
)
72+
assert.deepEqual(r[0], {
73+
address: 'info=protectmypublicmedia.org@mail172.atl101.mcdlv.net',
74+
comment: '',
75+
phrase: 'Anne Standley, PMPM',
76+
})
7577
// console.log(r);
7678
} catch (e) {
7779
console.error(e)
7880
}
79-
done()
8081
})
8182
})
8283

@@ -86,7 +87,12 @@ describe('parseReplyTo', function () {
8687
const r = address.parseReplyTo(
8788
'=?utf-8?Q?Anne=20Standley=2C=20Protect=20My=20Public=20Media?= <info@protectmypublicmedia.org>',
8889
)
89-
assert.equal(r[0].address, 'info@protectmypublicmedia.org')
90+
assert.deepEqual(r[0], {
91+
address: 'info@protectmypublicmedia.org',
92+
comment: '',
93+
phrase:
94+
'=?utf-8?Q?Anne=20Standley=2C=20Protect=20My=20Public=20Media?=',
95+
})
9096
// console.log(r);
9197
} catch (e) {
9298
console.error(e)

0 commit comments

Comments
 (0)