From 0a435c0e0e6845479ab00aab05792c76ba02e51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B5=AB=E7=84=B6?= Date: Thu, 5 Sep 2024 18:38:10 +0800 Subject: [PATCH] Add filename to attachment --- fileserver/fileop.go | 2 +- server/access-file.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fileserver/fileop.go b/fileserver/fileop.go index dfd6d449..cebef12a 100644 --- a/fileserver/fileop.go +++ b/fileserver/fileop.go @@ -527,7 +527,7 @@ func setCommonHeaders(rsp http.ResponseWriter, r *http.Request, operation, fileN operation == "downloadblks" { // Since the file name downloaded by safari will be garbled, we need to encode the filename. // Safari cannot parse unencoded utf8 characters. - contFileName = fmt.Sprintf("attachment;filename*=\"utf-8' '%s\"", url.PathEscape(fileName)) + contFileName = fmt.Sprintf("attachment;filename*=\"utf-8' '%s\";filename=\"%s\"", url.PathEscape(fileName), url.PathEscape(fileName)) } else { contFileName = fmt.Sprintf("inline;filename*=\"utf-8' '%s\"", url.PathEscape(fileName)) } diff --git a/server/access-file.c b/server/access-file.c index 75224437..08082c6a 100644 --- a/server/access-file.c +++ b/server/access-file.c @@ -605,7 +605,7 @@ do_file(evhtp_request_t *req, SeafRepo *repo, const char *file_id, strcmp(operation, "download-link") == 0) { /* Safari doesn't support 'utf8', 'utf-8' is compatible with most of browsers. */ snprintf(cont_filename, SEAF_PATH_MAX, - "attachment;filename*=\"utf-8\' \'%s\"", filename); + "attachment;filename*=\"utf-8\' \'%s\";filename=\"%s\"", filename, filename); } else { if (test_firefox (req)) { snprintf(cont_filename, SEAF_PATH_MAX,