Merge pull request #52 from matrix-org/michaelk/allow_json_files

Allow upload of files with a .json postfix.
This commit is contained in:
Michael Kaye 2022-02-08 15:02:09 +00:00 committed by GitHub
commit cc2374e431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

1
changelog.d/52.feature Normal file
View file

@ -0,0 +1 @@
Allow upload of Files with a .json postfix.

View file

@ -119,6 +119,9 @@ func extensionToMimeType(path string) string {
return "image/jpeg" return "image/jpeg"
} }
if strings.HasSuffix(path, ".json") {
return "application/json"
}
return "application/octet-stream" return "application/octet-stream"
} }

View file

@ -402,7 +402,7 @@ func formPartToPayload(field, data string, p *parsedPayload) {
// * no silly characters (/, ctrl chars, etc) // * no silly characters (/, ctrl chars, etc)
// //
// * nothing starting with '.' // * nothing starting with '.'
var filenameRegexp = regexp.MustCompile(`^[a-zA-Z0-9_-]+\.(jpg|png|txt)$`) var filenameRegexp = regexp.MustCompile(`^[a-zA-Z0-9_-]+\.(jpg|png|txt|json)$`)
// saveFormPart saves a file upload to the report directory. // saveFormPart saves a file upload to the report directory.
// //