Skip to content

Node.js based forum software built for the modern web

fix: #13779, svg uploads

Barış Soner Uşaklıe30024119334
diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js
index d2cfb48107..11fcebc95a 100644
--- a/src/controllers/uploads.js
+++ b/src/controllers/uploads.js
@@ -61,7 +61,7 @@ async function uploadAsImage(req, uploadedFile) {
throw new Error('[[error:no-privileges]]');
}
await image.checkDimensions(uploadedFile.path);
- await image.stripEXIF(uploadedFile.path);
+ await image.stripEXIF({ path: uploadedFile.path, type: uploadedFile.type });
if (plugins.hooks.hasListeners('filter:uploadImage')) {
return await plugins.hooks.fire('filter:uploadImage', {
diff --git a/src/image.js b/src/image.js
index 06e3f2d76d..0d60fddc6a 100644
--- a/src/image.js
+++ b/src/image.js
@@ -102,14 +102,15 @@ image.size = async function (path) {
return imageData ? { width: imageData.width, height: imageData.height } : undefined;
};
-image.stripEXIF = async function (path) {
- if (!meta.config.stripEXIFData || path.endsWith('.gif') || path.endsWith('.svg')) {
+image.stripEXIF = async function ({ path, type }) {
+ if (!meta.config.stripEXIFData || type === 'image/gif' || type === 'image/svg+xml') {
return;
}
try {
if (plugins.hooks.hasListeners('filter:image.stripEXIF')) {
await plugins.hooks.fire('filter:image.stripEXIF', {
path: path,
+ type: type,
});
return;
}