Skip to content

Commit db5b96f

Browse files
authored
Test content disposition against a content type with a parameter. (#664)
1 parent ac0371e commit db5b96f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/media_filename_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ func TestMediaFilenames(t *testing.T) {
137137
}
138138
})
139139

140+
t.Run("Will serve safe media types with parameters as inline", func(t *testing.T) {
141+
if runtime.Homeserver != runtime.Synapse {
142+
// We need to check that this security behaviour is being correctly run in
143+
// Synapse, but since this is not part of the Matrix spec we do not assume
144+
// other homeservers are doing so.
145+
t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse homeserver")
146+
}
147+
t.Parallel()
148+
149+
// Add parameters and upper-case, which should be parsed as text/plain.
150+
mxcUri := alice.UploadContent(t, data.MatrixPng, "", "Text/Plain; charset=utf-8")
151+
152+
_, isAttachment := downloadForFilename(t, bob, mxcUri, "")
153+
154+
if isAttachment {
155+
t.Fatal("Expected file to be served as inline")
156+
}
157+
})
158+
140159
t.Run("Will serve unsafe media types as attachments", func(t *testing.T) {
141160
if runtime.Homeserver != runtime.Synapse {
142161
// We need to check that this security behaviour is being correctly run in

0 commit comments

Comments
 (0)