From 59a3042ebcd209a0cc15998216ad9302173fbc77 Mon Sep 17 00:00:00 2001 From: petra-fied Date: Wed, 14 Apr 2021 19:08:18 +1000 Subject: [PATCH] added .rpa format support, new system extension set --- Cargo.lock | 2 +- src/extension_set.rs | 5 +++++ src/mime_db.rs | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 3ef6050..2378ecd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -321,7 +321,7 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mime_guess" version = "2.0.4" -source = "git+https://github.com/Lynnesbian/mime_guess#55fe99663a1b78ad5f50ffe1a9aaeb65fb2cb4ca" +source = "git+https://github.com/Lynnesbian/mime_guess#5432b3c1991372291a5e67457cc9307c85f77bd9" dependencies = [ "mime", "unicase", diff --git a/src/extension_set.rs b/src/extension_set.rs index 377b914..220d15a 100644 --- a/src/extension_set.rs +++ b/src/extension_set.rs @@ -18,6 +18,8 @@ pub enum ExtensionSet { Text, /// Extensions used for archive file formats, such as `zip`, `zst`, `gz`, etc. Archives, + /// Extensions used for system file formats, such as `mbr`, `crash`, `dll`, etc. + System, } impl ExtensionSet { @@ -39,6 +41,9 @@ impl ExtensionSet { Self::Text => mime_guess::get_mime_extensions_str("text/*").unwrap().to_vec(), // many compressed file types follow the name scheme "application/x.+compressed.*" - maybe this can be used // somehow to extract extensions for compressed files from mime_guess? + Self::Archives => vec!["zip", "tar", "gz", "zst", "xz", "rar", "7z", "bz", "bz2", "tgz", "rpa"], + Self::System => vec!["com", "dll", "exe", "sys", "reg", "nt", "cpl", "msi", "efi", "bio", "rcv", "mbr", "sbf", "grub", "ko", "dylib", "pdb", "hdmp", "crash", + ], Self::Archives => vec!["zip", "tar", "gz", "zst", "xz", "rar", "7z", "bz", "bz2", "tgz"], } } diff --git a/src/mime_db.rs b/src/mime_db.rs index a0f532e..0631534 100644 --- a/src/mime_db.rs +++ b/src/mime_db.rs @@ -39,6 +39,10 @@ cfg_if! { open_document_check(buf, "presentation") }); + info.add("application/x-rpa", "rpa", |buf| { + buf.len() >= 34 && buf.starts_with(b"RPA-") && buf[7] == b' ' && buf[24] ==b' ' + }); + info.add("image/svg+xml", "svg", |buf| { // before doing the moderately expensive SVG check, we should make sure that the input is actually SGML-ish // by "SGML-ish", i mean starts with anywhere from zero to ∞-1 whitespace characters, and then a less than sign,