summaryrefslogtreecommitdiffstats
path: root/system/libraries/Image_lib.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2018-02-14 19:57:20 +0100
committerAndrey Andreev <narf@devilix.net>2018-02-14 19:57:20 +0100
commit2e35167e8e8be5c91de2a09dcebb92e7a7410d8d (patch)
tree8d65413a72b5f03b12420951f0dd89b9c47992db /system/libraries/Image_lib.php
parent0b459da1d5bbbea07abef34765f55c1cb0b15814 (diff)
[ci skip] Apply #5394 (multibyte filename serving) to #5397 (Image_lib dynamic_output filename)
Diffstat (limited to 'system/libraries/Image_lib.php')
-rw-r--r--system/libraries/Image_lib.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index f37f25f5e..dbe5cbbd1 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1548,7 +1548,16 @@ class CI_Image_lib {
*/
public function image_display_gd($resource)
{
- header('Content-Disposition: filename='.basename(empty($this->new_image) ? $this->source_image : $this->new_image).';');
+ // RFC 6266 allows for multibyte filenames, but only in UTF-8,
+ // so we have to make it conditional ...
+ $filename = basename(empty($this->new_image) ? $this->source_image : $this->new_image);
+ $charset = strtoupper(config_item('charset'));
+ $utf8_filename = ($charset !== 'UTF-8')
+ ? get_instance()->utf8->convert_to_utf8($filename, $charset)
+ : $filename;
+ isset($utf8_filename[0]) && $utf8_filename = " filename*=UTF-8''".rawurlencode($utf8_filename);
+
+ header('Content-Disposition: filename="'.$filename.'";'.$utf8_filename);
header('Content-Type: '.$this->mime_type);
header('Content-Transfer-Encoding: binary');
header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');