From 46146b11d1763ed8a1ee79a0904dae40db6906ba Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 6 Oct 2023 10:35:32 -0400 Subject: [PATCH] Test content disposition against a content type with a parameter. --- tests/media_filename_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/media_filename_test.go b/tests/media_filename_test.go index 3ccca8e0..0203e239 100644 --- a/tests/media_filename_test.go +++ b/tests/media_filename_test.go @@ -137,6 +137,25 @@ func TestMediaFilenames(t *testing.T) { } }) + t.Run("Will serve safe media types with parameters as inline", func(t *testing.T) { + if runtime.Homeserver != runtime.Synapse { + // We need to check that this security behaviour is being correctly run in + // Synapse, but since this is not part of the Matrix spec we do not assume + // other homeservers are doing so. + t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse homeserver") + } + t.Parallel() + + // Add parameters and upper-case, which should be parsed as text/plain. + mxcUri := alice.UploadContent(t, data.MatrixPng, "", "Text/Plain; charset=utf-8") + + _, isAttachment := downloadForFilename(t, bob, mxcUri, "") + + if isAttachment { + t.Fatal("Expected file to be served as inline") + } + }) + t.Run("Will serve unsafe media types as attachments", func(t *testing.T) { if runtime.Homeserver != runtime.Synapse { // We need to check that this security behaviour is being correctly run in