Escape placeholder before injecting it into the style (#11607)
* Escape placeholder before injecting it into the style In particular this adds escaping for backslashes which was previously missing. * Update snapshots * Add tests
This commit is contained in:
parent
e9c9377e78
commit
3fbf38f17d
3 changed files with 19 additions and 5 deletions
|
@ -282,9 +282,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
|||
};
|
||||
|
||||
private showPlaceholder(): void {
|
||||
// escape single quotes
|
||||
const placeholder = this.props.placeholder?.replace(/'/g, "\\'");
|
||||
this.editorRef.current?.style.setProperty("--placeholder", `'${placeholder}'`);
|
||||
this.editorRef.current?.style.setProperty("--placeholder", `'${CSS.escape(this.props.placeholder ?? "")}'`);
|
||||
this.editorRef.current?.classList.add("mx_BasicMessageComposer_inputEmpty");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue