From 719e4acbafecbef3f143affb45a8dcd90945dd04 Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Tue, 30 Jan 2018 01:43:48 +0900 Subject: fix rfc6266 --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 02d4ce11e..338725477 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -149,7 +149,7 @@ if ( ! function_exists('force_download')) // Generate the server headers header('Content-Type: '.$mime); - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="'.$filename.'"; filename*=UTF-8\'\''.rawurlencode($filename)); header('Expires: 0'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.$filesize); -- cgit v1.2.3-24-g4f1b From a3e36019c787eb87fd0bc2e5ba9948c85c4a2c44 Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Thu, 1 Feb 2018 11:38:00 +0900 Subject: change filename. convert to utf-8 --- system/helpers/download_helper.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 338725477..93d468421 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -147,9 +147,24 @@ if ( ! function_exists('force_download')) @ob_clean(); } + $utf8_filename = $filename; + $encoding = config_item('charset'); + if (strtoupper($encoding) !== 'UTF-8') + { + if (MB_ENABLED) + { + $utf8_filename = mb_convert_encoding($utf8_filename, 'UTF-8', $encoding); + } + elseif (ICONV_ENABLED) + { + $utf8_filename = @iconv($encoding, 'UTF-8', $utf8_filename); + } + } + // Generate the server headers header('Content-Type: '.$mime); - header('Content-Disposition: attachment; filename="'.$filename.'"; filename*=UTF-8\'\''.rawurlencode($filename)); + // charset attribute (RFC 6266 only allows UTF-8) + header('Content-Disposition: attachment; filename="'.$filename.'"; filename*=UTF-8\'\''.rawurlencode($utf8_filename)); header('Expires: 0'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.$filesize); -- cgit v1.2.3-24-g4f1b From c755a6b0b32b58c86989e5c6cfd8085732b1e497 Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Thu, 1 Feb 2018 11:50:36 +0900 Subject: refactor use Utf8 class --- system/helpers/download_helper.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 93d468421..a169c3fd5 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -151,13 +151,10 @@ if ( ! function_exists('force_download')) $encoding = config_item('charset'); if (strtoupper($encoding) !== 'UTF-8') { - if (MB_ENABLED) + $CI =& get_instance(); + if ($converted_filename = $CI->utf8->convert_to_utf8($utf8_filename, $encoding) ) { - $utf8_filename = mb_convert_encoding($utf8_filename, 'UTF-8', $encoding); - } - elseif (ICONV_ENABLED) - { - $utf8_filename = @iconv($encoding, 'UTF-8', $utf8_filename); + $utf8_filename = $converted_filename; } } -- cgit v1.2.3-24-g4f1b From a70cdc5a9ed9e181e9f76fdc94006f3cc20198cd Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Mon, 5 Feb 2018 22:44:56 +0900 Subject: change use direct convert_to_utf8 method --- system/helpers/download_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index a169c3fd5..fdca76830 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -151,8 +151,8 @@ if ( ! function_exists('force_download')) $encoding = config_item('charset'); if (strtoupper($encoding) !== 'UTF-8') { - $CI =& get_instance(); - if ($converted_filename = $CI->utf8->convert_to_utf8($utf8_filename, $encoding) ) + $converted_filename = get_instance()->utf8->convert_to_utf8($utf8_filename, $encoding); + if ($converted_filename) { $utf8_filename = $converted_filename; } -- cgit v1.2.3-24-g4f1b From e5d719d822646a7c0bcd1a2732eb8fe19357444a Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Mon, 5 Feb 2018 23:04:17 +0900 Subject: Determine exactly whether converted filename is false --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index fdca76830..344fd4e9a 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -152,7 +152,7 @@ if ( ! function_exists('force_download')) if (strtoupper($encoding) !== 'UTF-8') { $converted_filename = get_instance()->utf8->convert_to_utf8($utf8_filename, $encoding); - if ($converted_filename) + if ($converted_filename !== FALSE) { $utf8_filename = $converted_filename; } -- cgit v1.2.3-24-g4f1b From 4dc34279cdc19b7a1df3385b1f679aeac6767c89 Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Mon, 5 Feb 2018 23:05:50 +0900 Subject: change variable name --- system/helpers/download_helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 344fd4e9a..afdb77956 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -148,10 +148,10 @@ if ( ! function_exists('force_download')) } $utf8_filename = $filename; - $encoding = config_item('charset'); - if (strtoupper($encoding) !== 'UTF-8') + $charset = config_item('charset'); + if (strtoupper($charset) !== 'UTF-8') { - $converted_filename = get_instance()->utf8->convert_to_utf8($utf8_filename, $encoding); + $converted_filename = get_instance()->utf8->convert_to_utf8($utf8_filename, $charset); if ($converted_filename !== FALSE) { $utf8_filename = $converted_filename; -- cgit v1.2.3-24-g4f1b From 8f04f20b0f63ace705e4371a24d0ddf139655dba Mon Sep 17 00:00:00 2001 From: ytetsuro Date: Tue, 6 Feb 2018 00:01:45 +0900 Subject: Changed to include Content-Disposition parameters in variables --- system/helpers/download_helper.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index afdb77956..43e12cf9e 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -147,21 +147,21 @@ if ( ! function_exists('force_download')) @ob_clean(); } - $utf8_filename = $filename; + $disposition = 'attachment; filename="'.$filename.'";'; $charset = config_item('charset'); if (strtoupper($charset) !== 'UTF-8') { - $converted_filename = get_instance()->utf8->convert_to_utf8($utf8_filename, $charset); - if ($converted_filename !== FALSE) + // charset attribute (RFC 6266 only allows UTF-8) + $utf8_filename = get_instance()->utf8->convert_to_utf8($filename, $charset); + if ($utf8_filename !== FALSE) { - $utf8_filename = $converted_filename; + $disposition .= ' filename*=UTF-8\'\''.rawurlencode($utf8_filename); } } // Generate the server headers header('Content-Type: '.$mime); - // charset attribute (RFC 6266 only allows UTF-8) - header('Content-Disposition: attachment; filename="'.$filename.'"; filename*=UTF-8\'\''.rawurlencode($utf8_filename)); + header('Content-Disposition: '.$disposition); header('Expires: 0'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.$filesize); -- cgit v1.2.3-24-g4f1b