From d519a28c50fc74bd61a6ebd96381fd93d33abfcb Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Mon, 12 Apr 2021 14:24:55 +0300 Subject: [PATCH] files: Don't use canonical path when serving file Otherwise, for symlink files, the content-disposition header would be set to the filename of the pointed-to file. Fixes #2128. --- actix-files/src/service.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/actix-files/src/service.rs b/actix-files/src/service.rs index d2db8503f..dc51ada18 100644 --- a/actix-files/src/service.rs +++ b/actix-files/src/service.rs @@ -83,10 +83,10 @@ impl Service for FilesService { }; // full file path - let path = match self.directory.join(&real_path).canonicalize() { - Ok(path) => path, - Err(err) => return Box::pin(self.handle_err(err, req)), - }; + let path = self.directory.join(&real_path); + if let Err(err) = path.canonicalize() { + return Box::pin(self.handle_err(err, req)); + } if path.is_dir() { if let Some(ref redir_index) = self.index {