Disallow links without protocol (e.g. starting with http(s)://) in LinkedText. (#32972)
* Disallow links without protocols in LinkedText. * Update tests
This commit is contained in:
@@ -14,7 +14,7 @@ test.describe("Message links", () => {
|
||||
await use({ roomId });
|
||||
},
|
||||
});
|
||||
for (const link of ["https://example.org", "example.org", "ftp://example.org"]) {
|
||||
for (const link of ["https://example.org", "ftp://example.org"]) {
|
||||
test(`should linkify a regular link '${link}'`, async ({ page, user, app, room }) => {
|
||||
await page.goto(`#/room/${room.roomId}`);
|
||||
// Needs to be unformatted so we test linkifing
|
||||
@@ -24,6 +24,13 @@ test.describe("Message links", () => {
|
||||
await expect(linkElement).toBeVisible();
|
||||
});
|
||||
}
|
||||
test("should NOT linkify a bare domain", async ({ page, user, app, room }) => {
|
||||
await page.goto(`#/room/${room.roomId}`);
|
||||
// Needs to be unformatted so we test linkifing
|
||||
await app.client.sendMessage(room.roomId, `Check out example.org`);
|
||||
const linkElement = page.locator(".mx_EventTile_last").getByRole("link", { name: "example.org" });
|
||||
await expect(linkElement).not.toBeVisible();
|
||||
});
|
||||
test("should linkify a User ID", async ({ page, user, app, room }) => {
|
||||
await page.goto(`#/room/${room.roomId}`);
|
||||
// Needs to be unformatted so we test linkifing
|
||||
|
||||
@@ -14,13 +14,7 @@ test.describe("Topic links", () => {
|
||||
await use({ roomId });
|
||||
},
|
||||
});
|
||||
for (const link of [
|
||||
"https://example.org",
|
||||
"example.org",
|
||||
"ftp://example.org",
|
||||
"#aroom:example.org",
|
||||
"@alice:example.org",
|
||||
]) {
|
||||
for (const link of ["https://example.org", "ftp://example.org", "#aroom:example.org", "@alice:example.org"]) {
|
||||
// Playwright treats '@' as a tag, so replace it to be safe
|
||||
test(`should linkify plaintext '${link.replace("@", "_@")}'`, async ({ page, user, app, room }) => {
|
||||
await app.client.sendStateEvent(
|
||||
|
||||
Reference in New Issue
Block a user