You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Escape opening square bracket too
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@ -156,6 +156,14 @@ describe('editor/deserialize', function() {
|
||||
expect(parts[1]).toStrictEqual({type: "user-pill", text: "Alice\\", resourceId: "@alice:hs.tld"});
|
||||
expect(parts[2]).toStrictEqual({type: "plain", text: "!"});
|
||||
});
|
||||
it('user pill with displayname containing opening square bracket', function() {
|
||||
const html = "Hi <a href=\"https://matrix.to/#/@alice:hs.tld\">Alice[</a>!";
|
||||
const parts = normalize(parseEvent(htmlMessage(html), createPartCreator()));
|
||||
expect(parts.length).toBe(3);
|
||||
expect(parts[0]).toStrictEqual({type: "plain", text: "Hi "});
|
||||
expect(parts[1]).toStrictEqual({type: "user-pill", text: "Alice[", resourceId: "@alice:hs.tld"});
|
||||
expect(parts[2]).toStrictEqual({type: "plain", text: "!"});
|
||||
});
|
||||
it('user pill with displayname containing closing square bracket', function() {
|
||||
const html = "Hi <a href=\"https://matrix.to/#/@alice:hs.tld\">Alice]</a>!";
|
||||
const parts = normalize(parseEvent(htmlMessage(html), createPartCreator()));
|
||||
|
@ -49,6 +49,12 @@ describe('editor/serialize', function() {
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe("<a href=\"https://matrix.to/#/@user:server\">Displayname\\</a>");
|
||||
});
|
||||
it('displaynames containing an opening square bracket work', function() {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.userPill("Displayname[", "@user:server")]);
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe("<a href=\"https://matrix.to/#/@user:server\">Displayname[</a>");
|
||||
});
|
||||
it('displaynames containing a closing square bracket work', function() {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.userPill("Displayname]", "@user:server")]);
|
||||
|
Reference in New Issue
Block a user