Page MenuHomePhorge

D25113.1737845711.diff
No OneTemporary

D25113.1737845711.diff

diff --git a/src/aphront/response/AphrontFileResponse.php b/src/aphront/response/AphrontFileResponse.php
--- a/src/aphront/response/AphrontFileResponse.php
+++ b/src/aphront/response/AphrontFileResponse.php
@@ -8,7 +8,14 @@
private $compressResponse;
private $mimeType;
+
+ /**
+ * Download filename
+ *
+ * This is NULL as default or a string.
+ */
private $download;
+
private $rangeMin;
private $rangeMax;
private $allowOrigins = array();
@@ -18,14 +25,31 @@
return $this;
}
+ /**
+ * Activate a download, and set the download filename
+ *
+ * @param $download mixed
+ * @return self
+ */
public function setDownload($download) {
- if (!phutil_nonempty_string($download)) {
- $download = 'untitled';
+
+ // Try converting any scalar to string
+ $download = (string)$download;
+
+ // Assume a nice default
+ if ($download === '') {
+ $download = 'untitled';
}
+
$this->download = $download;
return $this;
}
+ /**
+ * Get the download filename
+ *
+ * @return mixed
+ */
public function getDownload() {
return $this->download;
}
@@ -113,7 +137,7 @@
$headers[] = array('Content-Length', $content_len);
}
- if (strlen($this->getDownload())) {
+ if (phutil_nonempty_string($this->getDownload())) {
$headers[] = array('X-Download-Options', 'noopen');
$filename = $this->getDownload();

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 25, 22:55 (2 w, 17 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1149118
Default Alt Text
D25113.1737845711.diff (1 KB)

Event Timeline