mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-11-25 07:13:54 +00:00
fix(fs): recognise compressed file extensions in any letter case (#17017)
* fix(fs): recognise compressed file extensions in any letter case * fix(fs): compare extensions without allocating and trim the test * test(fs): keep only the uppercase extension checks --------- Co-authored-by: Ruslan Zaitsev <293677063+Dofam1nch1k@users.noreply.github.com>
This commit is contained in:
1 parent
d4df77e2fd
commit
a89a82f911
1 file changed
+8
-1
+8
-1
@@ -498,7 +498,7 @@ fn get_ext(name: &str) -> &str {
|
||||
fn is_compressed_file(name: &str) -> bool {
|
||||
let compressed_exts = ["xz", "gz", "zip", "7z", "rar", "bz2", "tgz", "png", "jpg"];
|
||||
let ext = get_ext(name);
|
||||
compressed_exts.contains(&ext)
|
||||
compressed_exts.iter().any(|x| ext.eq_ignore_ascii_case(x))
|
||||
}
|
||||
|
||||
pub fn validate_file_name_no_traversal(name: &str) -> ResultType<()> {
|
||||
@@ -1917,4 +1917,11 @@ mod tests {
|
||||
assert!(!src.exists());
|
||||
assert!(dst.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compressed_file_extensions_ignore_case() {
|
||||
// Cameras and phones name their photos IMG_0001.JPG.
|
||||
assert!(is_compressed_file("IMG_0001.JPG"));
|
||||
assert!(is_compressed_file("Backup.ZIP"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user