improved pre-OOXML office mime detection
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Lynne Megido 2021-04-14 16:49:14 +10:00
parent 21dfe93a05
commit 383f6a30f2
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 9 additions and 1 deletions

View file

@ -10,6 +10,7 @@ Dates are given in YYYY-MM-DD format.
- Added Text extension set - Added Text extension set
- More test coverage - More test coverage
- Fixed a very minor output bug relating to scanning symlinked directories - Fixed a very minor output bug relating to scanning symlinked directories
- Better detection for a specific formats (pre-OOXML Office, EXE, DLL)
### v0.2.11 (2021-04-04) ### v0.2.11 (2021-04-04)
#### Features #### Features

View file

@ -39,7 +39,12 @@ pub fn mime_type<T: MimeDb>(db: &T, path: &Path) -> io::Result<Option<Mime>> {
// another is ZIP - many file formats (DOCX, ODT, JAR...) are just ZIP files with particular data structures. // another is ZIP - many file formats (DOCX, ODT, JAR...) are just ZIP files with particular data structures.
// determining that a file is in one of the MS office formats in particular requires looking quite far into the // determining that a file is in one of the MS office formats in particular requires looking quite far into the
// file. // file.
&& mime != &Mime::from_str("application/zip").unwrap()); && mime != &Mime::from_str("application/zip").unwrap()
// doc/ppt/xls files are a subset of what's known as an "OLE2 compound document storage", at least according to
// shared-mime-info. if a pre-OOXML era MS office file is scanned and identified as x-ole-storage, reading further
// will allow it to be detected correctly as the appropriate filetype.
&& mime != &Mime::from_str("application/x-ole-storage").unwrap()
);
if r.is_some() { if r.is_some() {
return Ok(r); return Ok(r);
@ -89,6 +94,8 @@ cached! {
} }
} }
match exts { match exts {
Some(exts) => { Some(exts) => {
let possible_exts: Vec<String> = exts.iter().map(|e| String::from(*e)).collect(); let possible_exts: Vec<String> = exts.iter().map(|e| String::from(*e)).collect();