postal-mime 2.4.2 → 2.4.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.4.3](https://github.com/postalsys/postal-mime/compare/v2.4.2...v2.4.3) (2025-01-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **TextDecoder:** Do not reuse text decoders to avoid spilling data from one instance to another ([8b1013e](https://github.com/postalsys/postal-mime/commit/8b1013e52c878020b3705a2e702a560114f4c081))
9
+
3
10
  ## [2.4.2](https://github.com/postalsys/postal-mime/compare/v2.4.1...v2.4.2) (2025-01-24)
4
11
 
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postal-mime",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "Email parser for browser environments",
5
5
  "main": "./src/postal-mime.js",
6
6
  "exports": {
@@ -1,7 +1,5 @@
1
1
  export const textEncoder = new TextEncoder();
2
2
 
3
- const decoders = new Map();
4
-
5
3
  const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
6
4
 
7
5
  // Use a lookup table to find the index.
@@ -46,23 +44,7 @@ export function decodeBase64(base64) {
46
44
 
47
45
  export function getDecoder(charset) {
48
46
  charset = charset || 'utf8';
49
- if (decoders.has(charset)) {
50
- return decoders.get(charset);
51
- }
52
- let decoder;
53
- try {
54
- decoder = new TextDecoder(charset);
55
- } catch (err) {
56
- if (charset === 'utf8') {
57
- // is this even possible?
58
- throw err;
59
- }
60
- // use default
61
- return getDecoder();
62
- }
63
-
64
- decoders.set(charset, decoder);
65
- return decoder;
47
+ return new TextDecoder(charset);
66
48
  }
67
49
 
68
50
  /**
@@ -157,6 +139,7 @@ export function decodeWord(charset, encoding, str) {
157
139
  export function decodeWords(str) {
158
140
  let joinString = true;
159
141
  let done = false;
142
+
160
143
  while (!done) {
161
144
  let result = (str || '')
162
145
  .toString()
package/src/mime-node.js CHANGED
@@ -18,7 +18,6 @@ export default class MimeNode {
18
18
  this.state = 'header';
19
19
 
20
20
  this.headerLines = [];
21
- this.decoders = new Map();
22
21
 
23
22
  this.contentType = {
24
23
  value: 'text/plain',