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:
parent
d866af32e0
commit
5952b0a31b
|
@ -15,9 +15,8 @@ final class AphrontFileResponse extends AphrontResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDownload($download) {
|
public function setDownload($download) {
|
||||||
$download = preg_replace('/[^A-Za-z0-9_.-]/', '_', $download);
|
|
||||||
if (!strlen($download)) {
|
if (!strlen($download)) {
|
||||||
$download = 'untitled_document.txt';
|
$download = 'untitled';
|
||||||
}
|
}
|
||||||
$this->download = $download;
|
$this->download = $download;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -73,9 +72,10 @@ final class AphrontFileResponse extends AphrontResponse {
|
||||||
$headers[] = array('X-Download-Options', 'noopen');
|
$headers[] = array('X-Download-Options', 'noopen');
|
||||||
|
|
||||||
$filename = $this->getDownload();
|
$filename = $this->getDownload();
|
||||||
|
$filename = addcslashes($filename, '"\\');
|
||||||
$headers[] = array(
|
$headers[] = array(
|
||||||
'Content-Disposition',
|
'Content-Disposition',
|
||||||
'attachment; filename='.$filename,
|
'attachment; filename="'.$filename.'"',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue