Fixes formatted description in email + sanitize html everywhere (#7928)
* use sanitize-html instead * add list formatting * add lost changes from merging main * fixes caused by merge * remove dompurify * Revert "remove dompurify" This reverts commit 583bb623c7d3c0c7daa28e63ab2b1ac2da68c0d8. * sanitize already done in editor * Update yarn.lock --------- Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
26 files changed
+175
-87
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
|
||||
import { md } from "@calcom/lib/markdownIt";
|
||||
|
||||
export function markdownToSafeHTML(markdown: string | null) {
|
||||
if (!markdown) return null;
|
||||
|
||||
const html = md.render(markdown);
|
||||
|
||||
const safeHTML = sanitizeHtml(html);
|
||||
|
||||
const safeHTMLWithListFormatting = safeHTML
|
||||
.replace(
|
||||
/<ul>/g,
|
||||
"<ul style='list-style-type: disc; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"
|
||||
)
|
||||
.replace(
|
||||
/<ol>/g,
|
||||
"<ol style='list-style-type: decimal; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"
|
||||
);
|
||||
|
||||
return safeHTMLWithListFormatting;
|
||||
}
|
||||
Reference in new issue
Block a user