Ignore permalink_prefix when serializing pills (#11726)
* Ignore permalink_prefix when serializing Markdown fixes vector-im/element-web/issues/26002 During serialization of messages, pills were wrongfully serialized to a URL starting with `permalink_prefix`. This is against the Spec (which mandates https://matrix.to/#/ links) and the resulting pills were not recognized as pills in other clients. Spec-Appendix concerning matrix.to links: https://spec.matrix.org/v1.8/appendices/#matrixto-navigation Signed-off-by: Lars Wickel <git@herkulessi.de> * Test for pill serialization with permalink_prefix set Signed-off-by: Lars Wickel <git@herkulessi.de> * Test that permalink_prefix is used for permalink creation Signed-off-by: Lars Wickel <git@herkulessi.de> * Fix lint issues introduced Signed-off-by: Lars Wickel <git@herkulessi.de> * Incorporate requested changes Signed-off-by: Lars Wickel <git@herkulessi.de> --------- Signed-off-by: Lars Wickel <git@herkulessi.de> Co-authored-by: herkulessi <git@herkulessi.de> Co-authored-by: David Baker <dbkr@users.noreply.github.com>
This commit is contained in:
parent
e6a3238621
commit
fa60edf00f
4 changed files with 82 additions and 11 deletions
|
@ -37,7 +37,7 @@ export function mdSerialize(model: EditorModel): string {
|
|||
case Type.AtRoomPill:
|
||||
return html + part.text;
|
||||
case Type.RoomPill: {
|
||||
const url = makeGenericPermalink(part.resourceId);
|
||||
const url = makeGenericPermalink(part.resourceId, true);
|
||||
// Escape square brackets and backslashes
|
||||
// Here we use the resourceId for compatibility with non-rich text clients
|
||||
// See https://github.com/vector-im/element-web/issues/16660
|
||||
|
@ -45,7 +45,7 @@ export function mdSerialize(model: EditorModel): string {
|
|||
return html + `[${title}](${url})`;
|
||||
}
|
||||
case Type.UserPill: {
|
||||
const url = makeGenericPermalink(part.resourceId);
|
||||
const url = makeGenericPermalink(part.resourceId, true);
|
||||
// Escape square brackets and backslashes; convert newlines to HTML
|
||||
const title = part.text.replace(/[[\\\]]/g, (c) => "\\" + c).replace(/\n/g, "<br>");
|
||||
return html + `[${title}](${url})`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue