Remove previous commit, we actually have GuessMimeByFilename() in libcitadel for...
authorArt Cancro <ajc@citadel.org>
Wed, 13 Apr 2016 15:15:34 +0000 (11:15 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 13 Apr 2016 15:15:34 +0000 (11:15 -0400)
citadel/modules/image/serv_image.c
libcitadel/lib/mime_parser.c

index 2c7647f3fdca996b7b7c0628b615aeaf7362e246..9664b08732fa73fd735e7f6d08e6b46756ea412b 100644 (file)
@@ -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];
index 1fc037d43ffd77462434eb93f645001f4dbb251a..2e81fe8b07bcca291cd2ed736d41d7d0fb93b8e8 100644 (file)
@@ -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))