sanitize note title

This commit is contained in:
zadam
2022-07-05 22:40:41 +02:00
parent e7db262559
commit 4fc686bbbc
9 changed files with 21 additions and 13 deletions

View File

@@ -341,8 +341,10 @@ function downloadImages(noteId, content) {
const imageService = require('../services/image');
const {note} = imageService.saveImage(noteId, imageBuffer, "inline image", true, true);
const sanitizedTitle = note.title.replace(/[^a-z0-9-.]/gi, "");
content = content.substr(0, imageMatch.index)
+ `<img src="api/images/${note.noteId}/${note.title}"`
+ `<img src="api/images/${note.noteId}/${sanitizedTitle}"`
+ content.substr(imageMatch.index + imageMatch[0].length);
}
else if (!url.includes('api/images/')