Skip to content

Commit

Permalink
update zip
Browse files Browse the repository at this point in the history
  • Loading branch information
wuriyanto48 committed Jul 14, 2022
1 parent e30b27b commit 302f03d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var (
PDF = []byte{0x25, 0x50, 0x44, 0x46}
RAR = []byte{0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}
GZIP = []byte{0x1F, 0x8B, 0x08}
ZIP = []byte{0x50, 0x4B, 0x03, 0x04}
ZIP_0 = []byte{0x50, 0x4B, 0x03, 0x04}
ZIP_1 = []byte{0x50, 0x4B, 0x05, 0x06}
ZIP_2 = []byte{0x50, 0x4B, 0x07, 0x08}
WEBP = []byte{0x52, 0x49, 0x46, 0x46}
)
8 changes: 5 additions & 3 deletions validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,17 @@ func IsGzip(r io.ReadSeeker) bool {

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

buff, err := readUntil(l, r)
if err != nil {
return false
}

valid := bytes.Compare(ZIP, buff)
if valid != 0 {
valid_zip_0 := bytes.Compare(ZIP_0, buff)
valid_zip_1 := bytes.Compare(ZIP_0, buff)
valid_zip_2 := bytes.Compare(ZIP_2, buff)
if valid_zip_0 != 0 && valid_zip_1 != 0 && valid_zip_2 != 0 {
return false
}

Expand Down

0 comments on commit 302f03d

Please sign in to comment.