Move RFC5987 encoding function to UA class

This commit is contained in:
Kijin Sung 2016-06-25 21:22:32 +09:00
parent 8fe8c9203e
commit c3fe8d265b
2 changed files with 63 additions and 19 deletions

View file

@ -342,25 +342,8 @@ class fileController extends file
exit();
}
// Filename encoding for browsers that support RFC 5987
if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
{
$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
}
elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
{
$filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"';
}
// Filename encoding for browsers that do not support RFC 5987
elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{
$filename = rawurlencode($filename);
$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
}
else
{
$filename_param = 'filename="' . $filename . '"';
}
// Encode the filename.
$filename_param = Rhymix\Framework\UA::encodeFilenameForDownload($filename);
// Close context to prevent blocking the session
Context::close();