mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-31 08:57:00 +02:00
actix-files: fix handling linebreaks in filenames (#3237)
Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
@@ -139,8 +139,12 @@ impl NamedFile {
|
||||
_ => DispositionType::Attachment,
|
||||
};
|
||||
|
||||
// Replace newlines in filenames which could occur on some filesystems.
|
||||
let filename_s = filename.replace('\n', "%0A");
|
||||
// replace special characters in filenames which could occur on some filesystems
|
||||
let filename_s = filename
|
||||
.replace('\n', "%0A") // \n line break
|
||||
.replace('\x0B', "%0B") // \v vertical tab
|
||||
.replace('\x0C', "%0C") // \f form feed
|
||||
.replace('\r', "%0D"); // \r carriage return
|
||||
let mut parameters = vec![DispositionParam::Filename(filename_s)];
|
||||
|
||||
if !filename.is_ascii() {
|
||||
|
Reference in New Issue
Block a user