Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b6a490c

Browse files
authored
Merge pull request #10372 from matrix-org/backport-10370-to-staging
Roll back pillify everything (#10370)
2 parents 52420aa + 370c872 commit b6a490c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/components/views/messages/TextualBody.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ export default class TextualBody extends React.Component<IBodyProps, IState> {
9292
const showLineNumbers = SettingsStore.getValue("showCodeLineNumbers");
9393
this.activateSpoilers([content]);
9494

95-
HtmlUtils.linkifyElement(content);
95+
// pillifyLinks BEFORE linkifyElement because plain room/user URLs in the composer
96+
// are still sent as plaintext URLs. If these are ever pillified in the composer,
97+
// we should be pillify them here by doing the linkifying BEFORE the pillifying.
9698
pillifyLinks([content], this.props.mxEvent, this.pills);
99+
HtmlUtils.linkifyElement(content);
97100

98101
this.calculateUrlPreview();
99102

test/components/views/messages/TextualBody-test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,21 @@ describe("<TextualBody />", () => {
147147
);
148148
});
149149

150-
it("pillification of MXIDs get applied correctly into the DOM", () => {
150+
it("should not pillify MXIDs", () => {
151151
const ev = mkRoomTextMessage("Chat with @user:example.com");
152152
const { container } = getComponent({ mxEvent: ev });
153153
const content = container.querySelector(".mx_EventTile_body");
154154
expect(content.innerHTML).toMatchInlineSnapshot(
155-
`"Chat with <span><bdi><a class="mx_Pill mx_UserPill"><img class="mx_BaseAvatar mx_BaseAvatar_image" src="mxc://avatar.url/image.png" style="width: 16px; height: 16px;" alt="" data-testid="avatar-img" aria-hidden="true"><span class="mx_Pill_linkText">Member</span></a></bdi></span>"`,
155+
`"Chat with <a href="https://matrix.to/#/@user:example.com" class="linkified" rel="noreferrer noopener">@user:example.com</a>"`,
156156
);
157157
});
158158

159-
it("pillification of room aliases get applied correctly into the DOM", () => {
159+
it("should not pillify room aliases", () => {
160160
const ev = mkRoomTextMessage("Visit #room:example.com");
161161
const { container } = getComponent({ mxEvent: ev });
162162
const content = container.querySelector(".mx_EventTile_body");
163163
expect(content.innerHTML).toMatchInlineSnapshot(
164-
`"Visit <span><bdi><a class="mx_Pill mx_RoomPill" href="https://matrix.to/#/#room:example.com"><span class="mx_Pill_linkText">#room:example.com</span></a></bdi></span>"`,
164+
`"Visit <a href="https://matrix.to/#/#room:example.com" class="linkified" rel="noreferrer noopener">#room:example.com</a>"`,
165165
);
166166
});
167167
});

0 commit comments

Comments
 (0)