mirror of
https://github.com/1f349/dendrite.git
synced 2024-12-23 08:44:11 +00:00
Fix panic if upload name wasn't supplied (#351)
This commit is contained in:
parent
f42f44391f
commit
0d72e34acf
@ -21,6 +21,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
"github.com/matrix-org/dendrite/common/config"
|
"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."),
|
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{
|
return &util.JSONResponse{
|
||||||
Code: 400,
|
Code: 400,
|
||||||
JSON: jsonerror.Unknown("File name must not begin with '~'."),
|
JSON: jsonerror.Unknown("File name must not begin with '~'."),
|
||||||
|
Loading…
Reference in New Issue
Block a user