@postalsys/email-text-tools 2.0.0 → 2.1.0

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.
@@ -6,7 +6,9 @@ const htmlToText = compile({
6
6
  selectors: [
7
7
  { selector: 'p', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } },
8
8
  { selector: 'pre', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } },
9
- { selector: 'table.class#id', format: 'dataTable' }
9
+ { selector: 'table.class#id', format: 'dataTable' },
10
+ // ignore images
11
+ { selector: 'img', format: 'skip' }
10
12
  ],
11
13
  hideLinkHrefIfSameAsText: true
12
14
  });
package/lib/mime-html.js CHANGED
@@ -28,6 +28,35 @@ const FORBID_TAGS = [
28
28
  'video',
29
29
  'applet'
30
30
  ];
31
+
32
+ const FORBID_STYLES = [
33
+ 'all',
34
+ 'position',
35
+ 'clip',
36
+ 'animation',
37
+ 'float',
38
+ 'clear',
39
+ 'animation-delay',
40
+ 'animation-direction',
41
+ 'animation-duration',
42
+ 'animation-fill-mode',
43
+ 'animation-iteration-count',
44
+ 'animation-name',
45
+ 'animation-play-state',
46
+ 'animation-timing-function',
47
+ 'offset',
48
+ 'offset-anchor',
49
+ 'offset-distance',
50
+ 'offset-path',
51
+ 'offset-position',
52
+ 'offset-rotate',
53
+ 'paint-order',
54
+ 'scrollbar-color',
55
+ 'scrollbar-gutter',
56
+ 'scrollbar-width',
57
+ 'zoom'
58
+ ];
59
+
31
60
  // keep the style at first
32
61
  const FORBID_TAGS_ALL = ['style'].concat(FORBID_TAGS);
33
62
 
@@ -120,6 +149,23 @@ function mimeHtml(message) {
120
149
  dom.style.removeProperty('height');
121
150
  dom.style.removeProperty('min-height');
122
151
  dom.style.removeProperty('max-height');
152
+
153
+ // remove specific style properties for all DOM nodes
154
+ let walkDom = node => {
155
+ if (node.style) {
156
+ for (let disallowedStyle of FORBID_STYLES) {
157
+ node.style.removeProperty(disallowedStyle);
158
+ }
159
+ }
160
+
161
+ if (node.childNodes) {
162
+ for (let childNode of node.childNodes) {
163
+ walkDom(childNode);
164
+ }
165
+ }
166
+ };
167
+ walkDom(dom);
168
+
123
169
  let bodyStyles = (dom.getAttribute('style') || '').toString().trim();
124
170
 
125
171
  // embed into a styled container
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/email-text-tools",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Email text tools",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,11 +22,11 @@
22
22
  "eslint-config-prettier": "8.8.0"
23
23
  },
24
24
  "dependencies": {
25
- "dompurify": "3.0.2",
25
+ "dompurify": "3.0.3",
26
26
  "he": "1.2.0",
27
27
  "html-to-text": "9.0.5",
28
- "js-beautify": "1.14.7",
29
- "jsdom": "21.1.1",
28
+ "js-beautify": "1.14.8",
29
+ "jsdom": "22.1.0",
30
30
  "juice": "9.0.0",
31
31
  "linkify-it": "4.0.1",
32
32
  "moment-timezone": "0.5.43",