Skip to content

Commit aeea48d

Browse files
committed
Remove use of utf8_encode (deprecated in PHP 8.2)
1 parent 789d092 commit aeea48d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

classes/local/store/s3/client.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,13 @@ private function get_nice_filename($headers) {
604604

605605
if (!empty($originalfilename)) {
606606
$result['Content-Disposition'] = $contentdisposition;
607-
$result['filename'] = 'filename="' . utf8_encode($originalfilename) . '"';
607+
// The filename parameter must be in ISO-8859-1, however it works in browsers if
608+
// you treat the original UTF-8 string as ISO-8859-1 characters. To achieve that
609+
// here, we encode the UTF-8 as if it were ISO-8859-1. This behaviour is hideous
610+
// so it would be nice to use the optional filename* field (RFC 5987) but S3 still
611+
// complains if we do that.
612+
$jankyfilename = \core_text::convert($originalfilename, 'ISO-8859-1');
613+
$result['filename'] = 'filename="' . $jankyfilename . '"';
608614
$result['Content-Type'] = $originalcontenttype;
609615
}
610616
}

0 commit comments

Comments
 (0)