handle OPML with empty content, fixes #2495

This commit is contained in:
zadam 2021-12-30 21:06:45 +01:00
parent 265401775b
commit 6bc8773d5f
2 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,10 @@ const sanitizeHtml = require('sanitize-html');
// intended mainly as protection against XSS via import
// secondarily it (partly) protects against "CSS takeover"
function sanitize(dirtyHtml) {
if (!dirtyHtml) {
return dirtyHtml;
}
// avoid H1 per https://github.com/zadam/trilium/issues/1552
// demote H1, and if that conflicts with existing H2, demote that, etc
const transformTags = {};

View File

@ -51,7 +51,7 @@ async function importOpml(taskContext, fileBuffer, parentNote) {
throw new Error("Unrecognized OPML version " + opmlVersion);
}
content = htmlSanitizer.sanitize(content);
content = htmlSanitizer.sanitize(content || "");
const {note} = noteService.createNewNote({
parentNoteId,