Normalize filenames to Unicode Normal Form D before sanitisation

This commit is contained in:
xenofem 2022-04-30 15:14:28 -04:00
parent 3449ea1076
commit e95590ef07
3 changed files with 4 additions and 1 deletions

1
Cargo.lock generated
View file

@ -1416,6 +1416,7 @@ dependencies = [
"thiserror",
"time",
"tokio",
"unicode-normalization",
"zip",
]

View file

@ -28,6 +28,7 @@ serde_json = "1.0"
thiserror = "1"
time = "0.3.9"
tokio = { version = "1.17.0", features = ["full"] }
unicode-normalization = "0.1.19"
[dev-dependencies]
zip = "0.6.2"

View file

@ -8,6 +8,7 @@ use log::{debug, error, info, trace};
use rand::distributions::{Alphanumeric, DistString};
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use unicode_normalization::UnicodeNormalization;
use crate::store::{storage_dir, StoredFile, self};
@ -90,7 +91,7 @@ pub struct UploadedFile {
impl UploadedFile {
fn new(name: &str, size: u64, modtime: OffsetDateTime) -> Self {
Self {
name: sanitise_file_name::sanitise(name),
name: sanitise_file_name::sanitise(&name.nfd().collect::<String>()),
size,
modtime,
}