From cb68d38823870fa7adb5f0c2b68cf59205dd4bec Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 30 Nov 2020 03:00:37 +0000 Subject: CTAN sync 202011300300 --- support/pkgcheck/src/filemagic.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'support/pkgcheck/src/filemagic.rs') diff --git a/support/pkgcheck/src/filemagic.rs b/support/pkgcheck/src/filemagic.rs index 2ae8bfae6e..aa9c50feda 100644 --- a/support/pkgcheck/src/filemagic.rs +++ b/support/pkgcheck/src/filemagic.rs @@ -19,7 +19,6 @@ use unicode_bom::Bom; // - https://filesignatures.net/ // - https://github.com/7h3rAm/cigma/blob/master/cigma/magicbytes.json - #[derive(Debug, PartialEq)] pub enum LineEnding { LF, @@ -49,7 +48,6 @@ pub enum Mimetype { BOM(Bom), } - pub struct Filetype { buffer: Vec, } @@ -318,11 +316,11 @@ fn is_archive(vec: &[u8]) -> Option { r"^(?-u)\x52\x61\x72\x21\x1A\x07\x00", // RAR archive version 1.50 onwards r"^(?-u)\x52\x61\x72\x21\x1A\x07\x01\x00", // RAR archive version 5.0 onwards // https://en.wikipedia.org/wiki/LHA_(file_format) - r"^(?-u)..-lh[0124567d]", // LHarc (canonical LZH) - r"^(?-u)..-lh[89abce]", // LHarc (Joe Jared extensions) - r"^(?-u)..-lhx", // LHarc (UNLHA32 extensions) - r"^(?-u)..-(pc1|pm0|pm1|pm2|pms)", // LHarc (PMarc extensions) - r"^(?-u)..-lz[s234578]", // LHarc (LArc extensions) + r"^(?-u)..-lh[0124567d]", // LHarc (canonical LZH) + r"^(?-u)..-lh[89abce]", // LHarc (Joe Jared extensions) + r"^(?-u)..-lhx", // LHarc (UNLHA32 extensions) + r"^(?-u)..-(pc1|pm0|pm1|pm2|pms)", // LHarc (PMarc extensions) + r"^(?-u)..-lz[s234578]", // LHarc (LArc extensions) r"^(?-u)\x53\x5a\x44\x44\x88\xf0\x27\x33", // RAR archive version 5.0 onwards ]) .unwrap(); @@ -417,7 +415,10 @@ fn test_filetype() { assert!(ft.analyze("tests_filemagic/empty.zip").ok() == Some(Mimetype::Zip)); - assert!(ft.analyze("tests_filemagic/README").ok() == Some(Mimetype::Text(LineEnding::MIXED(0,0,0)))); + assert!( + ft.analyze("tests_filemagic/README").ok() + == Some(Mimetype::Text(LineEnding::MIXED(0, 0, 0))) + ); // assert!(ft.analyze("tests_filemagic/README1").ok() == Some(Mimetype::Text)); assert!(ft.analyze("tests_filemagic/cp").ok() == Some(Mimetype::Binary)); @@ -431,5 +432,8 @@ fn test_filetype() { assert!(ft.analyze("tests_filemagic/chap5.rtf").ok() == Some(Mimetype::Data)); assert!(ft.analyze("tests_filemagic/commons-math.jar").ok() == Some(Mimetype::Data)); - assert!(ft.analyze("tests_filemagic/8stbu11h.htm").ok() == Some(Mimetype::Text(LineEnding::MIXED(0,1,8710)))); + assert!( + ft.analyze("tests_filemagic/8stbu11h.htm").ok() + == Some(Mimetype::Text(LineEnding::MIXED(0, 1, 8710))) + ); } -- cgit v1.2.3