Skip to content

Commit d00c574

Browse files
authored
Merge pull request #69 from bojand/winzip
add support for winzip in is_zip. fixes #52 and possibly #49
2 parents 4181c4f + ef12bb4 commit d00c574

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/matchers/archive.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ pub fn is_zip(buf: &[u8]) -> bool {
88
buf.len() > 3
99
&& buf[0] == 0x50
1010
&& buf[1] == 0x4B
11-
&& (buf[2] == 0x3 || buf[2] == 0x5 || buf[2] == 0x7)
12-
&& (buf[3] == 0x4 || buf[3] == 0x6 || buf[3] == 0x8)
11+
&& (((buf[2] == 0x3 && buf[3] == 0x4)
12+
|| (buf[2] == 0x5 && buf[3] == 0x6)
13+
|| (buf[2] == 0x7 && buf[3] == 0x8))
14+
|| (
15+
// winzip
16+
buf.len() > 7
17+
&& (buf[2] == 0x30
18+
&& buf[3] == 0x30
19+
&& buf[4] == 0x50
20+
&& buf[5] == 0x4B
21+
&& buf[6] == 0x3
22+
&& buf[7] == 0x4)
23+
))
1324
}
1425

1526
/// Returns whether a buffer is a tar archive.

0 commit comments

Comments
 (0)