Skip to content

Commit

Permalink
fix: Content-Dispositionのヘッダを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
arata-nvm committed May 7, 2024
1 parent d6e14b6 commit 9db72cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/sos24-domain/src/entity/file_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl From<FileName> for ContentDisposition {

fn generate_content_disposition(value: &[u8]) -> String {
format!(
"attachment; filename*=UTF8''{}",
"attachment; filename*=UTF-8''{}",
percent_encoding::percent_encode(value, NON_ALPHANUMERIC)
)
}
Expand Down Expand Up @@ -126,19 +126,19 @@ mod test {
#[test]
fn encode_non_ascii_file_name() {
assert_eq!(
"attachment; filename*=UTF8''%E3%83%86%E3%82%B9%E3%83%88%2Etxt",
"attachment; filename*=UTF-8''%E3%83%86%E3%82%B9%E3%83%88%2Etxt",
generate_content_disposition("テスト.txt".as_bytes())
);
assert_eq!(
"attachment; filename*=UTF8''%E3%83%86%20%E3%82%B9%E3%83%88%2Etxt",
"attachment; filename*=UTF-8''%E3%83%86%20%E3%82%B9%E3%83%88%2Etxt",
generate_content_disposition("テ スト.txt".as_bytes())
)
}

#[test]
fn encode_injecting_file_name() {
assert_eq!(
"attachment; filename*=UTF8''example%22%3B%27%3B%2Etxt",
"attachment; filename*=UTF-8''example%22%3B%27%3B%2Etxt",
generate_content_disposition("example\";';.txt".as_bytes())
);
}
Expand Down

0 comments on commit 9db72cd

Please sign in to comment.