diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-06-02 18:59:43 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2021-06-02 19:22:17 +0200 |
commit | 377514aad14ad3c5297daf14b848ef470ae56f22 (patch) | |
tree | 9e486a65b287e35631ca15154e739b8810cacea6 /lib | |
parent | 2637f92d96d13037aed82cec53765d3206af8a4e (diff) | |
download | nextcloud-server-377514aad14ad3c5297daf14b848ef470ae56f22.tar.gz nextcloud-server-377514aad14ad3c5297daf14b848ef470ae56f22.zip |
Escape filename in Content-Disposition
We should escape all occurences of ' and \ in here.
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Http/DownloadResponse.php | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/public/AppFramework/Http/DownloadResponse.php b/lib/public/AppFramework/Http/DownloadResponse.php index 78381f0f08f..a7516fc6b85 100644 --- a/lib/public/AppFramework/Http/DownloadResponse.php +++ b/lib/public/AppFramework/Http/DownloadResponse.php @@ -30,20 +30,16 @@ namespace OCP\AppFramework\Http; * @since 7.0.0 */ class DownloadResponse extends Response { - private $filename; - private $contentType; - /** * Creates a response that prompts the user to download the file * @param string $filename the name that the downloaded file should have * @param string $contentType the mimetype that the downloaded file should have * @since 7.0.0 */ - public function __construct($filename, $contentType) { + public function __construct(string $filename, string $contentType) { parent::__construct(); - $this->filename = $filename; - $this->contentType = $contentType; + $filename = strtr($filename, ['"' => '\\"', '\\' => '\\\\']); $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); $this->addHeader('Content-Type', $contentType); |