@pyreon/document 0.11.5 → 0.11.7

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 (50) hide show
  1. package/README.md +7 -4
  2. package/lib/confluence-Bd3ua1Ut.js.map +1 -1
  3. package/lib/csv-COrS4qdy.js.map +1 -1
  4. package/lib/discord-BLUnkEh9.js.map +1 -1
  5. package/lib/docx-uNAel545.js.map +1 -1
  6. package/lib/email-D0bbfWq4.js.map +1 -1
  7. package/lib/google-chat-CkKCBUWC.js.map +1 -1
  8. package/lib/html-B5biprN2.js.map +1 -1
  9. package/lib/index.js.map +1 -1
  10. package/lib/markdown-CdtlFGC0.js.map +1 -1
  11. package/lib/notion-iG2C5bEY.js.map +1 -1
  12. package/lib/pdf-IuBgTb3T.js.map +1 -1
  13. package/lib/pptx-DXiMiYFM.js.map +1 -1
  14. package/lib/sanitize-O_3j1mNJ.js.map +1 -1
  15. package/lib/slack-BI3EQwYm.js.map +1 -1
  16. package/lib/svg-BKxumy-p.js.map +1 -1
  17. package/lib/teams-Cwz9lce0.js.map +1 -1
  18. package/lib/telegram-gYFqyMXb.js.map +1 -1
  19. package/lib/text-l1XNXBOC.js.map +1 -1
  20. package/lib/types/index.d.ts +27 -27
  21. package/lib/whatsapp-CjSGoOKx.js.map +1 -1
  22. package/lib/xlsx-Cvu4LBNy.js.map +1 -1
  23. package/package.json +21 -21
  24. package/src/builder.ts +36 -36
  25. package/src/download.ts +32 -32
  26. package/src/index.ts +5 -10
  27. package/src/nodes.ts +45 -45
  28. package/src/render.ts +43 -43
  29. package/src/renderers/confluence.ts +63 -63
  30. package/src/renderers/csv.ts +10 -10
  31. package/src/renderers/discord.ts +37 -37
  32. package/src/renderers/docx.ts +57 -57
  33. package/src/renderers/email.ts +72 -72
  34. package/src/renderers/google-chat.ts +34 -34
  35. package/src/renderers/html.ts +76 -76
  36. package/src/renderers/markdown.ts +42 -42
  37. package/src/renderers/notion.ts +60 -60
  38. package/src/renderers/pdf.ts +78 -78
  39. package/src/renderers/pptx.ts +51 -51
  40. package/src/renderers/slack.ts +48 -48
  41. package/src/renderers/svg.ts +47 -47
  42. package/src/renderers/teams.ts +67 -67
  43. package/src/renderers/telegram.ts +39 -39
  44. package/src/renderers/text.ts +43 -43
  45. package/src/renderers/whatsapp.ts +33 -33
  46. package/src/renderers/xlsx.ts +35 -35
  47. package/src/sanitize.ts +20 -20
  48. package/src/tests/document.test.ts +1302 -1302
  49. package/src/tests/stress.test.ts +110 -110
  50. package/src/types.ts +61 -61
package/src/sanitize.ts CHANGED
@@ -8,13 +8,13 @@
8
8
  * Blocks: semicolons, braces, angle brackets, quotes, backslashes, expressions.
9
9
  */
10
10
  export function sanitizeCss(value: string | undefined): string {
11
- if (value == null) return ""
11
+ if (value == null) return ''
12
12
  // Remove anything that could break out of a CSS value
13
13
  return value
14
- .replace(/[;{}()<>\\'"]/g, "")
15
- .replace(/expression\s*\(/gi, "")
16
- .replace(/url\s*\(/gi, "")
17
- .replace(/javascript\s*:/gi, "")
14
+ .replace(/[;{}()<>\\'"]/g, '')
15
+ .replace(/expression\s*\(/gi, '')
16
+ .replace(/url\s*\(/gi, '')
17
+ .replace(/javascript\s*:/gi, '')
18
18
  }
19
19
 
20
20
  /**
@@ -22,7 +22,7 @@ export function sanitizeCss(value: string | undefined): string {
22
22
  * Returns the value if valid, empty string if not.
23
23
  */
24
24
  export function sanitizeColor(value: string | undefined): string {
25
- if (value == null) return ""
25
+ if (value == null) return ''
26
26
  const trimmed = value.trim()
27
27
  // Hex: #fff, #ffffff, #ffffffff
28
28
  if (/^#[0-9a-fA-F]{3,8}$/.test(trimmed)) return trimmed
@@ -32,16 +32,16 @@ export function sanitizeColor(value: string | undefined): string {
32
32
  if (/^(rgb|hsl)a?\(\s*[\d.,\s%]+\)$/.test(trimmed)) return trimmed
33
33
  // transparent, inherit, currentColor
34
34
  if (/^(transparent|inherit|currentColor|initial|unset)$/i.test(trimmed)) return trimmed
35
- return ""
35
+ return ''
36
36
  }
37
37
 
38
38
  /**
39
39
  * Sanitize a color for XML attributes (DOCX/PPTX) — only hex without #.
40
40
  * Returns 6-char hex string or default.
41
41
  */
42
- export function sanitizeXmlColor(value: string | undefined, fallback = "000000"): string {
42
+ export function sanitizeXmlColor(value: string | undefined, fallback = '000000'): string {
43
43
  if (value == null) return fallback
44
- const hex = value.replace("#", "")
44
+ const hex = value.replace('#', '')
45
45
  if (/^[0-9a-fA-F]{3,8}$/.test(hex)) return hex
46
46
  return fallback
47
47
  }
@@ -51,13 +51,13 @@ export function sanitizeXmlColor(value: string | undefined, fallback = "000000")
51
51
  * Returns the URL if safe, empty string if not.
52
52
  */
53
53
  export function sanitizeHref(url: string | undefined): string {
54
- if (url == null) return ""
54
+ if (url == null) return ''
55
55
  const trimmed = url.trim()
56
56
  // Block dangerous protocols
57
- const lower = trimmed.toLowerCase().replace(/\s/g, "")
58
- if (lower.startsWith("javascript:")) return ""
59
- if (lower.startsWith("vbscript:")) return ""
60
- if (lower.startsWith("data:") && !lower.startsWith("data:image/")) return ""
57
+ const lower = trimmed.toLowerCase().replace(/\s/g, '')
58
+ if (lower.startsWith('javascript:')) return ''
59
+ if (lower.startsWith('vbscript:')) return ''
60
+ if (lower.startsWith('data:') && !lower.startsWith('data:image/')) return ''
61
61
  return trimmed
62
62
  }
63
63
 
@@ -66,12 +66,12 @@ export function sanitizeHref(url: string | undefined): string {
66
66
  * Blocks javascript:, vbscript:, and non-image data: URIs.
67
67
  */
68
68
  export function sanitizeImageSrc(src: string | undefined): string {
69
- if (src == null) return ""
69
+ if (src == null) return ''
70
70
  const trimmed = src.trim()
71
- const lower = trimmed.toLowerCase().replace(/\s/g, "")
72
- if (lower.startsWith("javascript:")) return ""
73
- if (lower.startsWith("vbscript:")) return ""
74
- if (lower.startsWith("data:") && !lower.startsWith("data:image/")) return ""
71
+ const lower = trimmed.toLowerCase().replace(/\s/g, '')
72
+ if (lower.startsWith('javascript:')) return ''
73
+ if (lower.startsWith('vbscript:')) return ''
74
+ if (lower.startsWith('data:') && !lower.startsWith('data:image/')) return ''
75
75
  return trimmed
76
76
  }
77
77
 
@@ -79,6 +79,6 @@ export function sanitizeImageSrc(src: string | undefined): string {
79
79
  * Sanitize a style attribute value — validates it's safe CSS.
80
80
  */
81
81
  export function sanitizeStyle(value: string | undefined): string {
82
- if (value == null) return ""
82
+ if (value == null) return ''
83
83
  return sanitizeCss(value)
84
84
  }