Przeglądaj źródła

fix: validate svg file extension in addition to client mime type

NGPixel 3 lat temu
rodzic
commit
57b56d3a5b
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      server/models/assets.js

+ 7 - 1
server/models/assets.js

@@ -100,7 +100,13 @@ module.exports = class Asset extends Model {
     }
     }
 
 
     // Sanitize SVG contents
     // Sanitize SVG contents
-    if (WIKI.config.uploads.scanSVG && opts.mimetype === 'image/svg+xml') {
+    if (
+      WIKI.config.uploads.scanSVG &&
+      (
+        opts.mimetype.toLowerCase().startsWith('image/svg') ||
+        opts.ext.toLowerCase() === 'svg'
+      )
+    ) {
       const svgSanitizeJob = await WIKI.scheduler.registerJob({
       const svgSanitizeJob = await WIKI.scheduler.registerJob({
         name: 'sanitize-svg',
         name: 'sanitize-svg',
         immediate: true,
         immediate: true,