You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +03:00
Fix escaped markdown passing backslashes through
Fixes https://github.com/vector-im/riot-web/issues/11230 Signed-off-by: Bob Rao <bob+git@vulpin.com>
This commit is contained in:
@ -41,6 +41,10 @@ export function htmlSerializeIfNeeded(model, {forceHTML = false} = {}) {
|
||||
if (!parser.isPlainText() || forceHTML) {
|
||||
return parser.toHTML();
|
||||
}
|
||||
// Format "plain" text to ensure removal of backslash escapes
|
||||
// https://github.com/vector-im/riot-web/issues/11230
|
||||
// https://github.com/vector-im/riot-web/issues/2870
|
||||
return parser.toPlaintext();
|
||||
}
|
||||
|
||||
export function textSerialize(model) {
|
||||
|
@ -43,4 +43,10 @@ describe('editor/serialize', function() {
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe("<em>hello</em> world");
|
||||
});
|
||||
it('escaped markdown should not retain backslashes', function() {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.plain('\\*hello\\* world')]);
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe('*hello* world');
|
||||
})
|
||||
});
|
||||
|
Reference in New Issue
Block a user