Handle newlines in user pills (#11166)

* Handle newlines in user pills

Fixes: vector-im/element-web#10994

* Fix typo in comment

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Refactor link generation for better readability

* Use `<br>` instead of `<br/>`

* Fix copy/paste error

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Johannes Marbach 2023-07-06 00:00:27 +02:00 committed by GitHub
parent 3f20675b93
commit d7677c7e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 16 deletions

View file

@ -22,7 +22,7 @@ import { logger } from "matrix-js-sdk/src/logger";
import { linkify } from "./linkify-matrix";
const ALLOWED_HTML_TAGS = ["sub", "sup", "del", "u"];
const ALLOWED_HTML_TAGS = ["sub", "sup", "del", "u", "br", "br/"];
// These types of node are definitely text
const TEXT_NODES = ["text", "softbreak", "linebreak", "paragraph", "document"];
@ -36,8 +36,8 @@ function isAllowedHtmlTag(node: commonmark.Node): boolean {
return true;
}
// Regex won't work for tags with attrs, but we only
// allow <del> anyway.
// Regex won't work for tags with attrs, but the tags we allow
// shouldn't really have any anyway.
const matches = /^<\/?(.*)>$/.exec(node.literal);
if (matches && matches.length == 2) {
const tag = matches[1];