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

Commit 8bc8c25

Browse files
[FIX] Escaping HTML on paste/drop Text (#471)
Co-authored-by: Martin Schoeler <[email protected]>
1 parent a48a85b commit 8bc8c25

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/Composer/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const parse = (plainText) =>
2525
[{ plain: plainText }]
2626
.map(({ plain, html }) => (plain ? escapeHtml(plain) : html || ''))
2727
.join('');
28+
2829
const findLastTextNode = (node) => {
2930
if (node.nodeType === Node.TEXT_NODE) {
3031
return node;
@@ -97,7 +98,7 @@ export class Composer extends Component {
9798
items.filter((item) => item.kind === 'string' && /^text\/plain/.test(item.type))
9899
.map((item) => new Promise((resolve) => item.getAsString(resolve))),
99100
);
100-
texts.forEach((text) => this.pasteText(text));
101+
texts.forEach((text) => this.pasteText(parse(text)));
101102
}
102103

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

126127
handleClick = () => {

0 commit comments

Comments
 (0)