Skip to content

Build your personal knowledge base with Trilium Notes

image handling consistency fixes

zadam51f094f87fec
diff --git a/src/routes/api/image.js b/src/routes/api/image.js
index 926d0e09c9..9e509ad378 100644
--- a/src/routes/api/image.js
+++ b/src/routes/api/image.js
@@ -34,7 +34,7 @@ function uploadImage(req) {
return [404, `Note ${noteId} doesn't exist.`];
}
- if (!["image/png", "image/jpeg", "image/gif", "image/webp"].includes(file.mimetype)) {
+ if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
return [400, "Unknown image type: " + file.mimetype];
}
@@ -56,7 +56,7 @@ function updateImage(req) {
return [404, `Note ${noteId} doesn't exist.`];
}
- if (!["image/png", "image/jpeg", "image/gif", "image/webp"].includes(file.mimetype)) {
+ if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
return {
uploaded: false,
message: "Unknown image type: " + file.mimetype
diff --git a/src/routes/api/sender.js b/src/routes/api/sender.js
index 34e7746e12..dac2116d80 100644
--- a/src/routes/api/sender.js
+++ b/src/routes/api/sender.js
@@ -8,7 +8,7 @@ const noteService = require('../../services/notes');
function uploadImage(req) {
const file = req.file;
- if (!["image/png", "image/jpeg", "image/gif"].includes(file.mimetype)) {
+ if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
return [400, "Unknown image type: " + file.mimetype];
}
diff --git a/src/services/import/enex.js b/src/services/import/enex.js
index fc569151be..b2c8e82034 100644
--- a/src/services/import/enex.js
+++ b/src/services/import/enex.js
@@ -215,7 +215,7 @@ function importEnex(taskContext, file, parentNote) {
content = extractContent(content);
- const noteEntity = (noteService.createNewNote({
+ const noteEntity = noteService.createNewNote({
parentNoteId: rootNote.noteId,
title,
content,
@@ -223,7 +223,7 @@ function importEnex(taskContext, file, parentNote) {
type: 'text',
mime: 'text/html',
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
- })).note;
+ }).note;
for (const attr of attributes) {
noteEntity.addAttribute(attr.type, attr.name, attr.value);
@@ -269,7 +269,7 @@ function importEnex(taskContext, file, parentNote) {
content = content.replace(mediaRegex, resourceLink);
};
- if (["image/jpeg", "image/png", "image/gif", "image/webp"].includes(resource.mime)) {
+ if (resource.mime && resource.mime.startsWith('image/')) {
try {
const originalName = "image." + resource.mime.substr(6);