From 6206c24b7ef0f03204e8354568f668de0b977aca Mon Sep 17 00:00:00 2001 From: Zachary Lee Andrews Date: Tue, 27 Feb 2024 12:23:16 -0500 Subject: [PATCH] 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/ --- src/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu.c b/src/menu.c index 9b534cd..fba60ca 100644 --- a/src/menu.c +++ b/src/menu.c @@ -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;