1
0
mirror of https://github.com/gophernicus/gophernicus.git synced 2024-11-03 04:27:17 -05:00

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

View File

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