1
0
Fork 0

Update menu.c: Fix JPEG detection.

The existing JPEG detection logic is too restrictive because it checks for the file header "FF D8 FF E0", which only matches JFIF-type JPEG images... Meanwhile EXIF JPEG images are more common these days.

For reference:
FF D8 = JPEG SOI (Start of Image) header
FF-D8-FF-E0 = JFIF
FF-D8-FF-E1 = EXIF
FF-D8-FF-E2 = CIFF
FF-D8-FF-E8 = SPIFF

As you can see checking for the SOI and then FF matches all extent types of JPEG images. \o/
This commit is contained in:
Zachary Lee Andrews 2024-02-27 12:23:16 -05:00 committed by GitHub
parent d7c297ae5f
commit 6206c24b7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -264,7 +264,7 @@ char gopher_filetype(state *st, char *file, char magic)
sstrncmp(buf, "GIF87a") == MATCH) return TYPE_GIF;
/* JPEG images */
if (sstrncmp(buf, "\377\330\377\340") == MATCH) return TYPE_IMAGE;
if (sstrncmp(buf, "\377\330\377") == MATCH) return TYPE_IMAGE;
/* PNG images */
if (sstrncmp(buf, "\211PNG") == MATCH) return TYPE_IMAGE;