From 4c5095f9fe63b42b729cf10d9bc1cd4a26abb83d Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Wed, 1 Dec 2021 15:15:47 +0000 Subject: [PATCH] fix(plugins/rtf-to-txt): remove metadata comments from beginning of file --- src/plugins/rtf-to-txt/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/rtf-to-txt/index.js b/src/plugins/rtf-to-txt/index.js index ac54e6ab1..dd8c191b2 100644 --- a/src/plugins/rtf-to-txt/index.js +++ b/src/plugins/rtf-to-txt/index.js @@ -79,15 +79,15 @@ async function plugin(server, options) { await fs.writeFile(tempFile, req.body); try { - /** - * `fixUtf8` function replaces most common incorrectly converted - * Windows-1252 to UTF-8 results with HTML equivalents. - * Refer to https://www.i18nqa.com/debug/utf8-debug.html for more info. - */ req.conversionResults.body = await unrtf.convert( tempFile, config.rtfToTxtOptions ); + + // Remove metadata comments UnRTF adds to beginning of file + req.conversionResults.body = req.conversionResults.body + .replace(/^###(?:\s){0,3}.*?(?:-){1,17}/ms, "") + .trim(); } catch (err) { /** * UnRTF will throw if the .rtf file provided