Skip to content

Commit

Permalink
More accurate detection for Shapefile (#253)
Browse files Browse the repository at this point in the history
More accurate detection for Shapefile
  • Loading branch information
dhanusaputra committed Feb 23, 2022
1 parent 51095b2 commit fdfefdd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/magic/geo.go
Expand Up @@ -11,6 +11,17 @@ func Shp(raw []byte, limit uint32) bool {
if len(raw) < 112 {
return false
}

if !(binary.BigEndian.Uint32(raw[0:4]) == 9994 &&
binary.BigEndian.Uint32(raw[4:8]) == 0 &&
binary.BigEndian.Uint32(raw[8:12]) == 0 &&
binary.BigEndian.Uint32(raw[12:16]) == 0 &&
binary.BigEndian.Uint32(raw[16:20]) == 0 &&
binary.BigEndian.Uint32(raw[20:24]) == 0 &&
binary.LittleEndian.Uint32(raw[28:32]) == 1000) {
return false
}

shapeTypes := []int{
0, // Null shape
1, // Point
Expand Down

0 comments on commit fdfefdd

Please sign in to comment.