Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix invalid html results in empty note

Ammar Ahmed51b226226eeb
diff --git a/packages/core/src/utils/html-parser.ts b/packages/core/src/utils/html-parser.ts
index 4ce7e83f5..d3774f522 100644
--- a/packages/core/src/utils/html-parser.ts
+++ b/packages/core/src/utils/html-parser.ts
@@ -30,7 +30,12 @@ export const parseHTML = (input: string) =>
: null;
export const sanitizeHtml = (html: string): string => {
+ if (!isHtmlValid(html)) {
+ return wrapInCodeBlock(html);
+ }
+
const inputHtml = normalizeToHtmlBody(html);
+
return getDomPurify().sanitize(inputHtml, {
RETURN_DOM: false,
ADD_TAGS: ["iframe"]