diff --git a/playwright/e2e/timeline/timeline.spec.ts b/playwright/e2e/timeline/timeline.spec.ts index 32cc14bd4615..ef67df6ffcaa 100644 --- a/playwright/e2e/timeline/timeline.spec.ts +++ b/playwright/e2e/timeline/timeline.spec.ts @@ -49,7 +49,7 @@ const expectAvatar = async (cli: Client, e: Locator, avatarUrl: string): Promise const url = await cli.evaluate( (client, { avatarUrl, size, resizeMethod }) => { // eslint-disable-next-line no-restricted-properties - return client.mxcUrlToHttp(avatarUrl, size, size, resizeMethod); + return client.mxcUrlToHttp(avatarUrl, size, size, resizeMethod, false, true); }, { avatarUrl, size, resizeMethod: AVATAR_RESIZE_METHOD }, ); diff --git a/src/customisations/Media.ts b/src/customisations/Media.ts index 415a7f4c5dc5..05f91325dd7e 100644 --- a/src/customisations/Media.ts +++ b/src/customisations/Media.ts @@ -80,7 +80,7 @@ export class Media { */ public get srcHttp(): string | null { // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.srcMxc) || null; + return this.client.mxcUrlToHttp(this.srcMxc, undefined, undefined, undefined, false, true) || null; } /** @@ -90,7 +90,7 @@ export class Media { public get thumbnailHttp(): string | null { if (!this.hasThumbnail) return null; // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.thumbnailMxc!); + return this.client.mxcUrlToHttp(this.thumbnailMxc!, undefined, undefined, undefined, false, true); } /** @@ -107,7 +107,7 @@ export class Media { width = Math.floor(width * window.devicePixelRatio); height = Math.floor(height * window.devicePixelRatio); // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.thumbnailMxc!, width, height, mode); + return this.client.mxcUrlToHttp(this.thumbnailMxc!, width, height, mode, false, true); } /** @@ -122,7 +122,7 @@ export class Media { width = Math.floor(width * window.devicePixelRatio); height = Math.floor(height * window.devicePixelRatio); // eslint-disable-next-line no-restricted-properties - return this.client.mxcUrlToHttp(this.srcMxc, width, height, mode); + return this.client.mxcUrlToHttp(this.srcMxc, width, height, mode, false, true); } /** diff --git a/test/components/views/messages/MImageBody-test.tsx b/test/components/views/messages/MImageBody-test.tsx index 3e10c199ef56..267636dae2d7 100644 --- a/test/components/views/messages/MImageBody-test.tsx +++ b/test/components/views/messages/MImageBody-test.tsx @@ -57,7 +57,7 @@ describe("", () => { }, }), }); - const url = "https://server/_matrix/media/v3/download/server/encrypted-image"; + const url = "https://server/_matrix/media/v3/download/server/encrypted-image?allow_redirect=false"; // eslint-disable-next-line no-restricted-properties cli.mxcUrlToHttp.mockImplementation( (mxcUrl: string, width?: number, height?: number, resizeMethod?: string, allowDirectLinks?: boolean) => { @@ -180,8 +180,9 @@ describe("", () => { }); it("should fall back to /download/ if /thumbnail/ fails", async () => { - const thumbUrl = "https://server/_matrix/media/v3/thumbnail/server/image?width=800&height=600&method=scale"; - const downloadUrl = "https://server/_matrix/media/v3/download/server/image"; + const thumbUrl = + "https://server/_matrix/media/v3/thumbnail/server/image?width=800&height=600&method=scale&allow_redirect=false"; + const downloadUrl = "https://server/_matrix/media/v3/download/server/image?allow_redirect=false"; const event = new MatrixEvent({ room_id: "!room:server", @@ -228,7 +229,7 @@ describe("", () => { mocked(global.URL.createObjectURL).mockReturnValue("blob:generated-thumb"); fetchMock.getOnce( - "https://server/_matrix/media/v3/download/server/image", + "https://server/_matrix/media/v3/download/server/image?allow_redirect=false", { body: fs.readFileSync(path.resolve(__dirname, "..", "..", "..", "images", "animated-logo.webp")), }, diff --git a/test/components/views/messages/__snapshots__/MImageBody-test.tsx.snap b/test/components/views/messages/__snapshots__/MImageBody-test.tsx.snap index 3ba381641bca..2de4826dca11 100644 --- a/test/components/views/messages/__snapshots__/MImageBody-test.tsx.snap +++ b/test/components/views/messages/__snapshots__/MImageBody-test.tsx.snap @@ -6,7 +6,7 @@ exports[` should generate a thumbnail if one isn't included for ani class="mx_MImageBody" >