Skip to content

Commit

Permalink
Merge pull request #340 from hlanderdev/master
Browse files Browse the repository at this point in the history
Fix html sanitizer paste feature to fallback on plain text format
  • Loading branch information
jimafisk authored Sep 6, 2024
2 parents 12e9d9b + 26fca61 commit 0594934
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions defaults/core/cms/html_sanitizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
export const plaintextPaste = e => {
e.preventDefault();
const rawHtmlPaste = (e.clipboardData || window.clipboardData).getData("text/html");
if (rawHtmlPaste === "") {
return;
}
const paste = HtmlSanitizer.SanitizeHtml(rawHtmlPaste);
const data = e.clipboardData || window.clipboardData;
const raw = data.getData("text/html") || data.getData("text");
const paste = HtmlSanitizer.SanitizeHtml(raw);
document.execCommand("insertHTML", false, paste);
}
Expand Down

0 comments on commit 0594934

Please sign in to comment.