Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

[FIX] Escaping HTML on paste/drop Text #471

Merged
merged 3 commits into from
Sep 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const parse = (plainText) =>
[{ plain: plainText }]
.map(({ plain, html }) => (plain ? escapeHtml(plain) : html || ''))
.join('');

const findLastTextNode = (node) => {
if (node.nodeType === Node.TEXT_NODE) {
return node;
Expand Down Expand Up @@ -97,7 +98,7 @@ export class Composer extends Component {
items.filter((item) => item.kind === 'string' && /^text\/plain/.test(item.type))
.map((item) => new Promise((resolve) => item.getAsString(resolve))),
);
texts.forEach((text) => this.pasteText(text));
texts.forEach((text) => this.pasteText(parse(text)));
}

handleDrop = (onUpload) => async (event) => {
Expand All @@ -120,7 +121,7 @@ export class Composer extends Component {
items.filter((item) => item.kind === 'string' && /^text\/plain/.test(item.type))
.map((item) => new Promise((resolve) => item.getAsString(resolve))),
);
texts.forEach((text) => this.pasteText(text));
texts.forEach((text) => this.pasteText(parse(text)));
}

handleClick = () => {
Expand Down