@browserless/screenshot 10.12.13 → 10.12.15

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/screenshot",
3
3
  "description": "Capture high-quality screenshots of websites with overlay support, device emulation, and automated image optimization.",
4
4
  "homepage": "https://browserless.js.org/#/?id=screenshoturl-options",
5
- "version": "10.12.13",
5
+ "version": "10.12.15",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -32,7 +32,7 @@
32
32
  "web-capture"
33
33
  ],
34
34
  "dependencies": {
35
- "@browserless/goto": "^10.12.13",
35
+ "@browserless/goto": "^10.12.14",
36
36
  "@kikobeats/content-type": "~1.0.4",
37
37
  "@kikobeats/time-span": "~1.0.12",
38
38
  "automad-prism-themes": "~0.3.7",
@@ -71,5 +71,5 @@
71
71
  "timeout": "2m",
72
72
  "workerThreads": false
73
73
  },
74
- "gitHead": "fb047633d1e18f426c4d598acec0323440c5083f"
74
+ "gitHead": "f6663d9a8b3ac2fdb28d524d7a4e3365e47dc972"
75
75
  }
@@ -76,10 +76,13 @@ const content = (payload, contentType) =>
76
76
 
77
77
  const language = contentType => (contentType === 'json' ? 'language-js' : 'language-text')
78
78
 
79
+ const escapeHtml = str =>
80
+ str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
81
+
79
82
  module.exports = (payload, { contentType, prism, theme }) => {
80
83
  const css = `${resetCSS}\n${theme}`
81
84
  const lang = language(contentType)
82
- const code = content(payload, contentType)
85
+ const code = escapeHtml(content(payload, contentType))
83
86
 
84
87
  return `<!DOCTYPE html>
85
88
  <html lang="en">
@@ -93,3 +96,5 @@ module.exports = (payload, { contentType, prism, theme }) => {
93
96
  </body>
94
97
  </html>`
95
98
  }
99
+
100
+ module.exports.escapeHtml = escapeHtml
@@ -43,8 +43,12 @@ const readTheme = async themeId => {
43
43
  return readFile(filePath)
44
44
  }
45
45
 
46
+ const { escapeHtml } = require('./html')
47
+
46
48
  module.exports = async themeId => {
47
- if (isHttpUrl(themeId)) return `<link rel="stylesheet" type="text/css" href="${themeId}">`
49
+ if (isHttpUrl(themeId)) {
50
+ return `<link rel="stylesheet" type="text/css" href="${escapeHtml(themeId)}">`
51
+ }
48
52
  CACHE[themeId] = CACHE[themeId] || (await readTheme(themeId))
49
53
  return `<style>${CACHE[themeId]}</style>`
50
54
  }