From 8fd32f012b2aed8235aaa20bd35ff6e2c8bc1714 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Tue, 15 Oct 2024 11:18:53 +0200 Subject: [PATCH] Lazyloaded jsdom dependency - we can move this later into the code to prevent it from being eagerly loaded and taking up CPU time and memory --- ghost/core/core/server/web/api/middleware/upload.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ghost/core/core/server/web/api/middleware/upload.js b/ghost/core/core/server/web/api/middleware/upload.js index a1b5cf0868..54862ec4c7 100644 --- a/ghost/core/core/server/web/api/middleware/upload.js +++ b/ghost/core/core/server/web/api/middleware/upload.js @@ -6,7 +6,6 @@ const errors = require('@tryghost/errors'); const config = require('../../../../shared/config'); const tpl = require('@tryghost/tpl'); const logging = require('@tryghost/logging'); -const {JSDOM} = require('jsdom'); const messages = { db: { @@ -160,6 +159,8 @@ const checkFileIsValid = (fileData, types, extensions) => { * */ const isSvgSafe = (filepath) => { + const {JSDOM} = require('jsdom'); + const fileContent = fs.readFileSync(filepath, 'utf8'); const document = new JSDOM(fileContent).window.document; document.body.innerHTML = fileContent;