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

Commit

Permalink
[FIX] Escaping HTML on paste/drop Text (#471)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Schoeler <martin.schoeler@rocket.chat>
  • Loading branch information
Shailesh351 and MartinSchoeler committed Sep 14, 2021
1 parent a48a85b commit 8bc8c25
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 8bc8c25

Please sign in to comment.