From 8ad5458e2a68edfd120a7eaed3bf9f7508b18928 Mon Sep 17 00:00:00 2001 From: ADecametre <66925945+ADecametre@users.noreply.github.com> Date: Thu, 30 Jan 2025 08:56:43 -0500 Subject: [PATCH] Fix broken images - Allowed img tags to be used in summaries --- libs/utils/src/namespaces/string.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/utils/src/namespaces/string.ts b/libs/utils/src/namespaces/string.ts index a5182393..ed866d9b 100644 --- a/libs/utils/src/namespaces/string.ts +++ b/libs/utils/src/namespaces/string.ts @@ -60,6 +60,19 @@ export const parseLayoutLocator = (payload: SortablePayload | null): LayoutLocat export const sanitize = (html: string, options?: sanitizeHtml.IOptions) => { return sanitizeHtml(html, { ...options, + allowedTags: [ + ...options?.allowedTags, + // default tags (https://www.npmjs.com/package/sanitize-html#default-options) + "address", "article", "aside", "footer", "header", "h1", "h2", "h3", "h4", + "h5", "h6", "hgroup", "main", "nav", "section", "blockquote", "dd", "div", + "dl", "dt", "figcaption", "figure", "hr", "li", "main", "ol", "p", "pre", + "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", + "em", "i", "kbd", "mark", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", + "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "caption", + "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", + // images + "img", + ], allowedAttributes: { ...options?.allowedAttributes, "*": ["class", "style"],