mime icon indicating copy to clipboard operation
mime copied to clipboard

lookupMimeType(path, headerBytes) returning TRUE on passing incorrect headerBytes as well

Open rastogitech opened this issue 8 months ago • 0 comments

Action:

  • For a particular file, verify whether the MIME type coming from its extension name and header bytes are both same.
  • Task performed: lookupMimeType('file.jpeg', headerBytes: [0x89])

Expected behaviour: FALSE

Actual result: TRUE

Description:

  • As per the magic_number.dart, the magic bytes of JPEG file is [0xFF, 0xD8].
  • So, calling lookupMimeType('file.jpeg', headerBytes: [0x89]) should have returned FALSE, instead of TRUE.
  • I'm passing header bytes explicitly, so the match must fail if the header bytes don't match with the magic bytes.

rastogitech avatar Jun 01 '24 17:06 rastogitech