mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
image handling consistency fixes
This commit is contained in:
parent
262a4fa3c7
commit
51f094f87f
@ -34,7 +34,7 @@ function uploadImage(req) {
|
|||||||
return [404, `Note ${noteId} doesn't exist.`];
|
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];
|
return [400, "Unknown image type: " + file.mimetype];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ function updateImage(req) {
|
|||||||
return [404, `Note ${noteId} doesn't exist.`];
|
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 {
|
return {
|
||||||
uploaded: false,
|
uploaded: false,
|
||||||
message: "Unknown image type: " + file.mimetype
|
message: "Unknown image type: " + file.mimetype
|
||||||
|
@ -8,7 +8,7 @@ const noteService = require('../../services/notes');
|
|||||||
function uploadImage(req) {
|
function uploadImage(req) {
|
||||||
const file = req.file;
|
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];
|
return [400, "Unknown image type: " + file.mimetype];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ function importEnex(taskContext, file, parentNote) {
|
|||||||
|
|
||||||
content = extractContent(content);
|
content = extractContent(content);
|
||||||
|
|
||||||
const noteEntity = (noteService.createNewNote({
|
const noteEntity = noteService.createNewNote({
|
||||||
parentNoteId: rootNote.noteId,
|
parentNoteId: rootNote.noteId,
|
||||||
title,
|
title,
|
||||||
content,
|
content,
|
||||||
@ -223,7 +223,7 @@ function importEnex(taskContext, file, parentNote) {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
mime: 'text/html',
|
mime: 'text/html',
|
||||||
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
|
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
|
||||||
})).note;
|
}).note;
|
||||||
|
|
||||||
for (const attr of attributes) {
|
for (const attr of attributes) {
|
||||||
noteEntity.addAttribute(attr.type, attr.name, attr.value);
|
noteEntity.addAttribute(attr.type, attr.name, attr.value);
|
||||||
@ -269,7 +269,7 @@ function importEnex(taskContext, file, parentNote) {
|
|||||||
content = content.replace(mediaRegex, resourceLink);
|
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 {
|
try {
|
||||||
const originalName = "image." + resource.mime.substr(6);
|
const originalName = "image." + resource.mime.substr(6);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user