From 0d72e34acf1b30727bf368c6201c1f20d1440bcd Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Nov 2017 15:45:03 +0000 Subject: [PATCH] Fix panic if upload name wasn't supplied (#351) --- src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go b/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go index aafc0230..46eb242d 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/routing/upload.go @@ -21,6 +21,7 @@ import ( "net/http" "net/url" "path" + "strings" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/common/config" @@ -188,7 +189,7 @@ func (r *uploadRequest) Validate(maxFileSizeBytes config.FileSizeBytes) *util.JS JSON: jsonerror.Unknown("HTTP Content-Type request header must be set."), } } - if r.MediaMetadata.UploadName[0] == '~' { + if strings.HasPrefix(string(r.MediaMetadata.UploadName), "~") { return &util.JSONResponse{ Code: 400, JSON: jsonerror.Unknown("File name must not begin with '~'."),