Normalize filenames to Unicode Normal Form D before sanitisation
This commit is contained in:
parent
3449ea1076
commit
e95590ef07
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1416,6 +1416,7 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time",
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"unicode-normalization",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ serde_json = "1.0"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
time = "0.3.9"
|
time = "0.3.9"
|
||||||
tokio = { version = "1.17.0", features = ["full"] }
|
tokio = { version = "1.17.0", features = ["full"] }
|
||||||
|
unicode-normalization = "0.1.19"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
zip = "0.6.2"
|
zip = "0.6.2"
|
|
@ -8,6 +8,7 @@ use log::{debug, error, info, trace};
|
||||||
use rand::distributions::{Alphanumeric, DistString};
|
use rand::distributions::{Alphanumeric, DistString};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
use unicode_normalization::UnicodeNormalization;
|
||||||
|
|
||||||
use crate::store::{storage_dir, StoredFile, self};
|
use crate::store::{storage_dir, StoredFile, self};
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ pub struct UploadedFile {
|
||||||
impl UploadedFile {
|
impl UploadedFile {
|
||||||
fn new(name: &str, size: u64, modtime: OffsetDateTime) -> Self {
|
fn new(name: &str, size: u64, modtime: OffsetDateTime) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: sanitise_file_name::sanitise(name),
|
name: sanitise_file_name::sanitise(&name.nfd().collect::<String>()),
|
||||||
size,
|
size,
|
||||||
modtime,
|
modtime,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue