Skip to content

Commit

Permalink
#6898 Fix incompatible file download names in Chrome/Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed May 24, 2021
1 parent f711592 commit 3df5242
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion classes/services/PKPFileService.inc.php
Expand Up @@ -164,7 +164,7 @@ public function download($fileId, $filename, $inline = false)
header("Content-Type: ${mimetype}");
header("Content-Length: ${filesize}");
header('Accept-Ranges: none');
header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename*=UTF-8''\"${encodedFilename}\"");
header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . ";filename=\"$encodedFilename\";filename*=UTF-8''\"$encodedFilename\"");
header('Cache-Control: private'); // Workarounds for IE weirdness
header('Pragma: public');

Expand Down
3 changes: 2 additions & 1 deletion cypress/tests/integration/Filenames.spec.js
Expand Up @@ -9,7 +9,8 @@
describe('Filename support for different character sets', function() {
it('#6898 Tests submission file download name is correct', function() {
var name = 'edição-£$L<->/4/ch 丹尼爾 a دانيال1d line \\n break.pdf';
var responseHeader = 'attachment; filename*=UTF-8\'\'"edi%C3%A7%C3%A3o-%C2%A3%24L%3C-%3E%2F4%2Fch+%E4%B8%B9%E5%B0%BC%E7%88%BE+a+%D8%AF%D8%A7%D9%86%D9%8A%D8%A7%D9%841d+line+%5Cn+break.pdf"';
var encodedName = 'edi%C3%A7%C3%A3o-%C2%A3%24L%3C-%3E%2F4%2Fch+%E4%B8%B9%E5%B0%BC%E7%88%BE+a+%D8%AF%D8%A7%D9%86%D9%8A%D8%A7%D9%841d+line+%5Cn+break.pdf';
var responseHeader = 'attachment;filename="' + encodedName + '";filename*=UTF-8\'\'"' + encodedName + '"';
var stageId = Cypress.env('contextTitles').en_US === 'Public Knowledge Preprint Server' ? 5 : 1;
var downloadUrl = 'index.php/publicknowledge/$$$call$$$/api/file/file-api/download-file?submissionFileId=1&submissionId=1&stageId=' + stageId;

Expand Down

0 comments on commit 3df5242

Please sign in to comment.