From 951570a97f50dda0905ea1ecc4e779a2357642c3 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 22 Jul 2020 00:44:01 +0000 Subject: [PATCH] Escape single quotes in composer placeholder Signed-off-by: Robin Townsend --- src/components/views/rooms/BasicMessageComposer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/BasicMessageComposer.tsx b/src/components/views/rooms/BasicMessageComposer.tsx index 1e0a639aac..2a909bdd26 100644 --- a/src/components/views/rooms/BasicMessageComposer.tsx +++ b/src/components/views/rooms/BasicMessageComposer.tsx @@ -219,7 +219,9 @@ export default class BasicMessageEditor extends React.Component }; private showPlaceholder() { - this.editorRef.current.style.setProperty("--placeholder", `'${this.props.placeholder}'`); + // escape single quotes + const placeholder = this.props.placeholder.replace(/'/g, '\\\''); + this.editorRef.current.style.setProperty("--placeholder", `'${placeholder}'`); this.editorRef.current.classList.add("mx_BasicMessageComposer_inputEmpty"); }