Skip to content

Commit

Permalink
Merge pull request #137 from savel999/master
Browse files Browse the repository at this point in the history
match xls formats: biff5,biff8(11),biff8(12)
  • Loading branch information
h2non committed Oct 27, 2023
2 parents 462b61f + 99ad8a4 commit dd4cc89
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions matchers/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ func Docx(buf []byte) bool {

func Xls(buf []byte) bool {
if len(buf) > 513 {
return buf[0] == 0xD0 && buf[1] == 0xCF &&
buf[2] == 0x11 && buf[3] == 0xE0 &&
buf[512] == 0x09 && buf[513] == 0x08
} else {
return len(buf) > 3 &&
buf[0] == 0xD0 && buf[1] == 0xCF &&
buf[2] == 0x11 && buf[3] == 0xE0
isMSOfficeBFF := buf[0] == 0xD0 && buf[1] == 0xCF && buf[2] == 0x11 && buf[3] == 0xE0

switch {
case isMSOfficeBFF && buf[512] == 0x09 && buf[513] == 0x08: // BIFF5 && BIFF12(12)
return true
case isMSOfficeBFF && buf[512] == 0xFD && buf[513] == 0xFF: // BIFF12(11)
return true
}
}

return false
}

func Xlsx(buf []byte) bool {
Expand Down

0 comments on commit dd4cc89

Please sign in to comment.