added .rpa format support, new system extension set

This commit is contained in:
petra-fied 2021-04-14 19:08:18 +10:00
parent 383f6a30f2
commit 59a3042ebc
3 changed files with 10 additions and 1 deletions

2
Cargo.lock generated
View File

@ -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",

View File

@ -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"],
}
}

View File

@ -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,