From 370c872d70d074a0063e20f93f27a907f192a365 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 14 Mar 2023 11:56:14 +0100 Subject: [PATCH] Roll back pillify everything (#10370) (cherry picked from commit 05e3fb09d6e2a51b7cccbb02b371be71423bbfd7) --- src/components/views/messages/TextualBody.tsx | 5 ++++- test/components/views/messages/TextualBody-test.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index dc7cc4dc23..1bfc05505e 100644 --- a/src/components/views/messages/TextualBody.tsx +++ b/src/components/views/messages/TextualBody.tsx @@ -92,8 +92,11 @@ export default class TextualBody extends React.Component { const showLineNumbers = SettingsStore.getValue("showCodeLineNumbers"); this.activateSpoilers([content]); - HtmlUtils.linkifyElement(content); + // pillifyLinks BEFORE linkifyElement because plain room/user URLs in the composer + // are still sent as plaintext URLs. If these are ever pillified in the composer, + // we should be pillify them here by doing the linkifying BEFORE the pillifying. pillifyLinks([content], this.props.mxEvent, this.pills); + HtmlUtils.linkifyElement(content); this.calculateUrlPreview(); diff --git a/test/components/views/messages/TextualBody-test.tsx b/test/components/views/messages/TextualBody-test.tsx index 149cb7ae47..f5466c46cf 100644 --- a/test/components/views/messages/TextualBody-test.tsx +++ b/test/components/views/messages/TextualBody-test.tsx @@ -147,21 +147,21 @@ describe("", () => { ); }); - it("pillification of MXIDs get applied correctly into the DOM", () => { + it("should not pillify MXIDs", () => { const ev = mkRoomTextMessage("Chat with @user:example.com"); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); expect(content.innerHTML).toMatchInlineSnapshot( - `"Chat with Member"`, + `"Chat with @user:example.com"`, ); }); - it("pillification of room aliases get applied correctly into the DOM", () => { + it("should not pillify room aliases", () => { const ev = mkRoomTextMessage("Visit #room:example.com"); const { container } = getComponent({ mxEvent: ev }); const content = container.querySelector(".mx_EventTile_body"); expect(content.innerHTML).toMatchInlineSnapshot( - `"Visit #room:example.com"`, + `"Visit #room:example.com"`, ); }); });