1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Stop mangling filenames when downloading them

Summary: Fixes T6990. We unnecessarily mangle filenames when downloading them.

Test Plan:
  - Reviewed "quoted-string" grammar in HTTP spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html)
  - Downloaded some non-latin binaries.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6990

Differential Revision: https://secure.phabricator.com/D11940
This commit is contained in:
epriestley 2015-03-03 03:27:42 -08:00
parent d866af32e0
commit 5952b0a31b

View file

@ -15,9 +15,8 @@ final class AphrontFileResponse extends AphrontResponse {
}
public function setDownload($download) {
$download = preg_replace('/[^A-Za-z0-9_.-]/', '_', $download);
if (!strlen($download)) {
$download = 'untitled_document.txt';
$download = 'untitled';
}
$this->download = $download;
return $this;
@ -73,9 +72,10 @@ final class AphrontFileResponse extends AphrontResponse {
$headers[] = array('X-Download-Options', 'noopen');
$filename = $this->getDownload();
$filename = addcslashes($filename, '"\\');
$headers[] = array(
'Content-Disposition',
'attachment; filename='.$filename,
'attachment; filename="'.$filename.'"',
);
}