Skip to content

Commit

Permalink
Fix false-positive in ARW detection (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen authored and sindresorhus committed Oct 22, 2019
1 parent 2f69644 commit f379c5b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Binary file added fixture/fixture5.arw
Binary file not shown.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ const fileType = input => {

if (
check([0x49, 0x49, 0x2A, 0x00]) &&
(check([0x10, 0xFB, 0x86, 0x01], {offset: 4}) ||
check([0x08, 0x00, 0x00, 0x00, 0x13, 0x00], {offset: 4}) ||
check([0x08, 0x00, 0x00, 0x00, 0x12, 0x00], {offset: 4}))
(check([0x10, 0xFB, 0x86, 0x01], {offset: 4}) || check([0x08, 0x00, 0x00, 0x00], {offset: 4})) &&
// This pattern differentiates ARW from other TIFF-ish file types:
check([0x00, 0xFE, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x01], {offset: 9})
) {
return {
ext: 'arw',
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const names = {
'fixture',
'fixture2',
'fixture3',
'fixture4'
'fixture4',
'fixture5'
],
dng: [
'fixture',
Expand Down

0 comments on commit f379c5b

Please sign in to comment.