From 8e107e6f8eac3a92214d2c056493ae6d66ee91b1 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 24 Jun 2022 11:50:17 +0100 Subject: [PATCH] Set utf-8 encoding in signed URL filename header Change-Id: Ia71b2789783da26e2c10875f2a4edf3d1b3951cd --- classes/local/store/s3/client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index 3f10e9d5..d8b031f1 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -536,7 +536,7 @@ private function generate_presigned_url_cloudfront($contenthash, array $headers $result = $this->get_nice_filename($headers); if (!empty($result)) { $key .= '?response-content-disposition=' . - rawurlencode($result['Content-Disposition'] . ';' . $result['filename']) . + rawurlencode($result['Content-Disposition']) . ';' . $result['filename'] . '&response-content-type=' . rawurlencode($result['Content-Type']); } else { $key .= ''; @@ -604,7 +604,7 @@ private function get_nice_filename($headers) { if (!empty($originalfilename)) { $result['Content-Disposition'] = $contentdisposition; - $result['filename'] = 'filename="' . utf8_encode($originalfilename) . '"'; + $result['filename'] = "filename*=utf-8''" . rawurlencode($originalfilename); $result['Content-Type'] = $originalcontenttype; } }