@postalsys/ee-client 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +7 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -134,15 +134,18 @@ function splitAddressField(value) {
134
134
  }
135
135
 
136
136
  function parseAddressEntry(entry) {
137
- const match = entry.match(/^(.*)<([^>]*)>$/);
138
- if (!match) {
137
+ // "Name <address>": the address is between the last "<" and a closing ">" at the end.
138
+ // Found by index rather than a /^(.*)<([^>]*)>$/ match, which backtracks in quadratic
139
+ // time on a long run of "<" without the closing ">"
140
+ const open = entry.lastIndexOf('<');
141
+ if (open < 0 || !entry.endsWith('>') || entry.indexOf('>', open) !== entry.length - 1 || /[\n\r\u2028\u2029]/.test(entry.slice(0, open))) {
139
142
  return { address: entry };
140
143
  }
141
- let name = match[1].trim();
144
+ let name = entry.slice(0, open).trim();
142
145
  if (name.length > 1 && name.startsWith('"') && name.endsWith('"')) {
143
146
  name = name.slice(1, -1).replace(/\\(.)/g, '$1');
144
147
  }
145
- const address = match[2].trim();
148
+ const address = entry.slice(open + 1, -1).trim();
146
149
  return name ? { name, address } : { address };
147
150
  }
148
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/ee-client",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "EmailEngine client library for browser and Node.js applications",
5
5
  "main": "index.js",
6
6
  "module": "index.js",