diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index d4babe8cf..2958eae66 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,10 +2,11 @@ ## Unreleased +- Fix handling of special characters in filenames. + ## 0.6.4 -- Fix handling of linebreaks in filenames. [#3237] -- Fix handling of newlines in filenames. [#3235] +- Fix handling of newlines in filenames. - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. ## 0.6.3 diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 967ed1fa4..5b1f14eed 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -569,7 +569,7 @@ mod tests { } #[actix_rt::test] - async fn test_static_files_with_newlines() { + async fn test_static_files_with_special_characters() { // Create the file we want to test against ad-hoc. We can't check it in as otherwise // Windows can't even checkout this repository. let temp_dir = tempfile::tempdir().unwrap(); diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index 1d3fa3085..9e4a37737 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -139,12 +139,12 @@ impl NamedFile { _ => DispositionType::Attachment, }; - // Replace newlines and other line breaks in filenames which could occur on some filesystems. + // replace special characters in filenames which could occur on some filesystems let filename_s = filename - .replace('\n', "%0A") + .replace('\n', "%0A") // \n line break .replace('\x0B', "%0B") // \v vertical tab .replace('\x0C', "%0C") // \f form feed - .replace('\r', "%0D"); + .replace('\r', "%0D"); // \r carriage return let mut parameters = vec![DispositionParam::Filename(filename_s)]; if !filename.is_ascii() {