mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-05 02:55:31 +00:00
chore: add comments about RAR 4.x and 5.0 signature
This commit is contained in:
parent
8c32d2c31a
commit
22d4e0faf0
@ -98,6 +98,9 @@ pub fn try_infer_extension(path: &Path) -> Option<Extension> {
|
||||
buf.starts_with(&[0x28, 0xB5, 0x2F, 0xFD])
|
||||
}
|
||||
fn is_rar(buf: &[u8]) -> bool {
|
||||
// ref https://www.rarlab.com/technote.htm#rarsign
|
||||
// RAR 5.0 8 bytes length signature: 0x52 0x61 0x72 0x21 0x1A 0x07 0x01 0x00
|
||||
// RAR 4.x 7 bytes length signature: 0x52 0x61 0x72 0x21 0x1A 0x07 0x00
|
||||
buf.len() >= 7
|
||||
&& buf.starts_with(&[0x52, 0x61, 0x72, 0x21, 0x1A, 0x07])
|
||||
&& (buf[6] == 0x00 || (buf.len() >= 8 && buf[6..=7] == [0x01, 0x00]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user