mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Return UTF-8 filenames
This commit is contained in:
parent
0e2375c3b2
commit
12c8373f93
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
@ -302,7 +303,14 @@ func (r *downloadRequest) respondFromLocalFile(
|
||||||
responseMetadata = r.MediaMetadata
|
responseMetadata = r.MediaMetadata
|
||||||
|
|
||||||
if len(responseMetadata.UploadName) > 0 {
|
if len(responseMetadata.UploadName) > 0 {
|
||||||
w.Header().Set("Content-Disposition", fmt.Sprintf(`inline; filename*=utf-8"%s"`, responseMetadata.UploadName))
|
uploadName, err := url.PathUnescape(string(responseMetadata.UploadName))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("url.PathUnescape: %w", err)
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Disposition", fmt.Sprintf(
|
||||||
|
`inline; filename=utf-8"%s"`,
|
||||||
|
strconv.Quote(uploadName),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue