Update the magic number for JPEG to just FF D8 FF. (flutter/engine#32076)

This commit is contained in:
Harry Terkelsen
2022-03-16 15:53:34 -07:00
committed by GitHub
parent e3b4bee064
commit c502114887
2 changed files with 8 additions and 4 deletions

View File

@@ -297,10 +297,7 @@ class ImageFileFormat {
ImageFileFormat(<int?>[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], 'image/gif'),
// JPEG
ImageFileFormat(<int?>[0xFF, 0xD8, 0xFF, 0xDB], 'image/jpeg'),
ImageFileFormat(<int?>[0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01], 'image/jpeg'),
ImageFileFormat(<int?>[0xFF, 0xD8, 0xFF, 0xEE], 'image/jpeg'),
ImageFileFormat(<int?>[0xFF, 0xD8, 0xFF, 0xE1], 'image/jpeg'),
ImageFileFormat(<int?>[0xFF, 0xD8, 0xFF], 'image/jpeg'),
// WebP
ImageFileFormat(<int?>[0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50], 'image/webp'),

View File

@@ -529,6 +529,13 @@ void _testForImageCodecs({required bool useBrowserImageDecoder}) {
await disposePlatformView(0);
});
test('can detect JPEG from just magic number', () async {
expect(
detectContentType(
Uint8List.fromList(<int>[0xff, 0xd8, 0xff, 0xe2, 0x0c, 0x58, 0x49, 0x43, 0x43, 0x5f])),
'image/jpeg');
});
});
}