Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test content disposition against a content type with a parameter. #664

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/media_filename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess the reason you're not using runtime.SkipIf is because you want to only run this test on synapse, rather than skip if it is dendrite/conduit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is what the other tests in this file used and I copied & pasted the test to bootstrap. 😄

}
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
Expand Down
Loading