Skip to content

Commit

Permalink
Use the first 3 bytes to validate JPEG headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
blueimp committed Nov 7, 2018
1 parent 1da893f commit fac6b5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/php/UploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,8 @@ protected function imagetype($file_path) {
if ($data === 'GIF8') {
return self::IMAGETYPE_GIF;
}
// JPG: FF D8
if (bin2hex(substr($data, 0, 2)) === 'ffd8') {
// JPG: FF D8 FF
if (bin2hex(substr($data, 0, 3)) === 'ffd8ff') {
return self::IMAGETYPE_JPEG;
}
// PNG: 89 50 4E 47
Expand Down

0 comments on commit fac6b5f

Please sign in to comment.