Skip to content

Commit

Permalink
Remove use of utf8_encode (deprecated in PHP 8.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sammarshallou committed Feb 19, 2024
1 parent 789d092 commit 9e0101e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion classes/local/store/s3/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,14 @@ private function get_nice_filename($headers) {

if (!empty($originalfilename)) {
$result['Content-Disposition'] = $contentdisposition;
$result['filename'] = 'filename="' . utf8_encode($originalfilename) . '"';
// The filename parameter must be in ISO-8859-1, however it works in browsers if
// you treat the original UTF-8 string as ISO-8859-1 characters. To achieve that
// here, we encode the UTF-8 as if it were ISO-8859-1. Because this behaviour is
// hideous, we also supply the original UTF-8 as the optional 'filename*' field
// which is supposed to take precedence, and supports a specified encoding.
$jankyfilename = \core_text::convert($originalfilename, 'ISO-8859-1');
$result['filename'] = 'filename="' . $jankyfilename .
'"; filename*=UTF-8\'\'"' . $originalfilename . '"';
$result['Content-Type'] = $originalcontenttype;
}
}
Expand Down

0 comments on commit 9e0101e

Please sign in to comment.