Skip to content

Commit

Permalink
Merge pull request #295 from sohosai/develop
Browse files Browse the repository at this point in the history
deploy 20240507
  • Loading branch information
arata-nvm authored May 7, 2024
2 parents 5a0524c + 7c66f47 commit 420a310
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 420a310

Please sign in to comment.