mime
mime copied to clipboard
lookupMimeType(path, headerBytes) returning TRUE on passing incorrect headerBytes as well
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 ofJPEG
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.