Skip to content

Commit 268d3df

Browse files
sammarshalloumatthewhilton
authored andcommitted
Remove use of utf8_encode (deprecated in PHP 8.2)
1 parent f024f8e commit 268d3df

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

classes/local/store/s3/client.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,13 @@ private function get_nice_filename($headers) {
667667

668668
if (!empty($originalfilename)) {
669669
$result['Content-Disposition'] = $contentdisposition;
670-
$result['filename'] = 'filename="' . utf8_encode($originalfilename) . '"';
670+
// The filename parameter must be in ISO-8859-1, however it works in browsers if
671+
// you treat the original UTF-8 string as ISO-8859-1 characters. To achieve that
672+
// here, we encode the UTF-8 as if it were ISO-8859-1. This behaviour is hideous
673+
// so it would be nice to use the optional filename* field (RFC 5987) but S3 still
674+
// complains if we do that.
675+
$jankyfilename = \core_text::convert($originalfilename, 'ISO-8859-1');
676+
$result['filename'] = 'filename="' . $jankyfilename . '"';
671677
$result['Content-Type'] = $originalcontenttype;
672678
}
673679
}

0 commit comments

Comments
 (0)