From e3f6ab99716cc32ae913a92b5ed4b351eff65a41 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 13 Apr 2016 11:15:34 -0400 Subject: [PATCH] Remove previous commit, we actually have GuessMimeByFilename() in libcitadel for this. --- citadel/modules/image/serv_image.c | 4 +--- libcitadel/lib/mime_parser.c | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/citadel/modules/image/serv_image.c b/citadel/modules/image/serv_image.c index 2c7647f3f..9664b0873 100644 --- a/citadel/modules/image/serv_image.c +++ b/citadel/modules/image/serv_image.c @@ -98,7 +98,6 @@ void cmd_ului(char *cmdbuf) } // Check to make sure the user exists - // FIXME do this struct ctdluser usbuf; if (CtdlGetUser(&usbuf, username) != 0) { // check for existing user, don't lock it yet cprintf("%d %s not found.\n", ERROR + NO_SUCH_USER , username); @@ -141,8 +140,7 @@ void import_one_userpic_file(char *username, long usernum, char *path) fread(unencoded_data, data_length, 1, fp); char *encoded_data = malloc((data_length * 2) + 100); if (encoded_data) { - // FIXME try to guess the content-type based on the filename, don't assume GIF - sprintf(encoded_data, "Content-type: image/gif\nContent-transfer-encoding: base64\n\n"); + sprintf(encoded_data, "Content-type: %s\nContent-transfer-encoding: base64\n\n", GuessMimeByFilename(path, strlen(path))); CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1); char userconfigroomname[ROOMNAMELEN]; diff --git a/libcitadel/lib/mime_parser.c b/libcitadel/lib/mime_parser.c index 1fc037d43..2e81fe8b0 100644 --- a/libcitadel/lib/mime_parser.c +++ b/libcitadel/lib/mime_parser.c @@ -982,6 +982,8 @@ const char* GuessMimeByFilename(const char *what, size_t len) return "text/x-component"; else if ((len > 3) && !strncasecmp(&what[len - 4], ".jpg", 4)) return "image/jpeg"; + else if ((len > 4) && !strncasecmp(&what[len - 5], ".jpeg", 5)) + return "image/jpeg"; else if ((len > 3) && !strncasecmp(&what[len - 4], ".png", 4)) return "image/png"; else if ((len > 3) && !strncasecmp(&what[len - 4], ".ico", 4)) -- 2.30.2