-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downloads are broken because of semicolon appended to filename #13919
Comments
I always hated the Content-Disposition header. The current implementation in Phalcon is suitable for the simplest cases - when the filename is without any encodings and spaces, like filename.txt. For more complex file names each browser will react differently. Just look at this Test case: http://test.greenbytes.de/tech/tc2231/ if ($browserInfo['browser_name'] === 'Internet Explorer' && ($browserInfo['browser_version'] === '7.0' || $browserInfo['browser_version'] == '8.0')) {
$filename = mb_convert_encoding($filename, 'UTF-8', 'Windows-1251');
$contentDisposition = 'attachment; filename="' . rawurlencode($filename) . '"';
} elseif ($browserInfo['browser_name'] === 'Safari') {
$filename = mb_convert_encoding($filename, 'UTF-8', 'Windows-1251');
$contentDisposition = 'attachment; filename="' . $filename . '"';
} else {
$filename = mb_convert_encoding($filename, 'UTF-8', 'Windows-1251');
$contentDisposition = 'attachment; filename="' . $filename . '"; filename*=UTF-8\'\'' . rawurlencode($filename);
}
$this->response->setHeader("Content-Disposition", $contentDisposition); Fortunately, Internet Explorer 7.0 and 8.0 are already dead, but Safari can still be a problem. And yes, in any of these cases you don't need a semicolon at the end, but the filename must be enclosed in quotes. |
Fixes #13919, make response->setFileToSend support non-ASCII filename.
Fixed in the |
Changes from #13496 breaks our all downloads. Downloaded file has semicolon appended to the extension which disable file type recognition by system (which is important). Tested both linux and windows, chrome and firefox. Even RFC 6266 Content-Disposition in HTTP omits semicolon at the end of header. Browser does not strip this. Tried to wrap filename in double quotes but with no luck. Only solution is to overwrite Content-Disposition header to remove semicolon from the end.
Details
The text was updated successfully, but these errors were encountered: