mirror of https://github.com/Requarks/wiki.git
No known key found for this signature in database
GPG Key ID: 8FDA2F1757F60D63
6 changed files with 79 additions and 25 deletions
Split View
Diff Options
-
14client/components/admin/admin-security.vue
-
1server/app/data.yml
-
6server/graph/resolvers/site.js
-
48server/graph/schemas/site.graphql
-
25server/jobs/sanitize-svg.js
-
10server/models/assets.js
@ -0,0 +1,25 @@ |
|||
const fs = require('fs-extra') |
|||
const { JSDOM } = require('jsdom') |
|||
const createDOMPurify = require('dompurify') |
|||
|
|||
/* global WIKI */ |
|||
|
|||
module.exports = async (svgPath) => { |
|||
WIKI.logger.info(`Sanitizing SVG file upload...`) |
|||
|
|||
try { |
|||
let svgContents = await fs.readFile(svgPath, 'utf8') |
|||
|
|||
const window = new JSDOM('').window |
|||
const DOMPurify = createDOMPurify(window) |
|||
|
|||
svgContents = DOMPurify.sanitize(svgContents) |
|||
|
|||
await fs.writeFile(svgPath, svgContents) |
|||
WIKI.logger.info(`Sanitized SVG file upload: [ COMPLETED ]`) |
|||
} catch (err) { |
|||
WIKI.logger.error(`Failed to sanitize SVG file upload: [ FAILED ]`) |
|||
WIKI.logger.error(err.message) |
|||
throw err |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save