Skip to content

Commit

Permalink
Add filename to attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Sep 5, 2024
1 parent ced9830 commit 0a435c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fileserver/fileop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion server/access-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0a435c0

Please sign in to comment.