From b59c175c2e8e3a03464926727f209baa4b8434b2 Mon Sep 17 00:00:00 2001 From: azivner Date: Fri, 25 Jan 2019 21:34:14 +0100 Subject: [PATCH] add HTML header with UTF-8 meta encoding declaration to exported HTML files, fixes #384 --- src/services/export/single.js | 4 ++++ src/services/export/tar.js | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/export/single.js b/src/services/export/single.js index 7a47abc21..c6cc979dd 100644 --- a/src/services/export/single.js +++ b/src/services/export/single.js @@ -20,6 +20,10 @@ async function exportSingleNote(branch, format, res) { if (note.type === 'text') { if (format === 'html') { + if (!note.content.toLowerCase().includes("'; + } + payload = html.prettyPrint(note.content, {indent_size: 2}); extension = 'html'; mime = 'text/html'; diff --git a/src/services/export/tar.js b/src/services/export/tar.js index b99a0029d..9a42aedfb 100644 --- a/src/services/export/tar.js +++ b/src/services/export/tar.js @@ -74,11 +74,10 @@ async function exportToTar(branch, format, res) { return; } - const baseFileName = branch.prefix ? (branch.prefix + ' - ' + note.title) : note.title; + const baseFileName = sanitize(branch.prefix ? (branch.prefix + ' - ' + note.title) : note.title); if (note.noteId in noteIdToMeta) { - const sanitizedFileName = sanitize(baseFileName + ".clone"); - const fileName = getUniqueFilename(existingFileNames, sanitizedFileName); + const fileName = getUniqueFilename(existingFileNames, baseFileName + ".clone"); return { isClone: true, @@ -150,6 +149,10 @@ async function exportToTar(branch, format, res) { function prepareContent(note, format) { if (format === 'html') { + if (!note.content.toLowerCase().includes("'; + } + return html.prettyPrint(note.content, {indent_size: 2}); } else if (format === 'markdown') {