From 670a4617526e2ab6d9e2a6683bc5b8c14526d314 Mon Sep 17 00:00:00 2001 From: Igor Kaldowski Date: Sat, 4 Dec 2021 21:07:43 +0000 Subject: [PATCH] Strip html from opf descriptions --- server/utils/parseOpfMetadata.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/utils/parseOpfMetadata.js b/server/utils/parseOpfMetadata.js index 74df3e6a..f48603de 100644 --- a/server/utils/parseOpfMetadata.js +++ b/server/utils/parseOpfMetadata.js @@ -1,4 +1,5 @@ const { xmlToJSON } = require('./index') +const { stripHtml } = require("string-strip-html") function parseCreators(metadata) { if (!metadata['dc:creator']) return null @@ -56,7 +57,7 @@ function fetchDescription(metadata) { // check if description is HTML or plain text. only plain text allowed // calibre stores < and > as < and > description = description.replace(/</g, '<').replace(/>/g, '>') - if (description.match(/|<\/?\s*[a-z-][^>]*\s*>|(\&(?:[\w\d]+|#\d+|#x[a-f\d]+);)/)) return null + if (description.match(/|<\/?\s*[a-z-][^>]*\s*>|(\&(?:[\w\d]+|#\d+|#x[a-f\d]+);)/)) return stripHtml(description).result return description }