Skip to content

Commit 302f03d

Browse files
committed
update zip
1 parent e30b27b commit 302f03d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

signature.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var (
2626
PDF = []byte{0x25, 0x50, 0x44, 0x46}
2727
RAR = []byte{0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}
2828
GZIP = []byte{0x1F, 0x8B, 0x08}
29-
ZIP = []byte{0x50, 0x4B, 0x03, 0x04}
29+
ZIP_0 = []byte{0x50, 0x4B, 0x03, 0x04}
30+
ZIP_1 = []byte{0x50, 0x4B, 0x05, 0x06}
31+
ZIP_2 = []byte{0x50, 0x4B, 0x07, 0x08}
3032
WEBP = []byte{0x52, 0x49, 0x46, 0x46}
3133
)

validator.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,17 @@ func IsGzip(r io.ReadSeeker) bool {
360360

361361
// IsZip function will return true if File is a valid ZIP
362362
func IsZip(r io.ReadSeeker) bool {
363-
l := len(ZIP)
363+
l := len(ZIP_0)
364364

365365
buff, err := readUntil(l, r)
366366
if err != nil {
367367
return false
368368
}
369369

370-
valid := bytes.Compare(ZIP, buff)
371-
if valid != 0 {
370+
valid_zip_0 := bytes.Compare(ZIP_0, buff)
371+
valid_zip_1 := bytes.Compare(ZIP_0, buff)
372+
valid_zip_2 := bytes.Compare(ZIP_2, buff)
373+
if valid_zip_0 != 0 && valid_zip_1 != 0 && valid_zip_2 != 0 {
372374
return false
373375
}
374376

0 commit comments

Comments
 (0)