Skip to content

Commit

Permalink
chore: add comments about RAR 4.x and 5.0 signature
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 authored and marcospb19 committed Dec 2, 2024
1 parent 8c32d2c commit 22d4e0f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down

0 comments on commit 22d4e0f

Please sign in to comment.