# HG changeset patch # User Evan Schoenberg # Date 1181045049 0 # Node ID 0a42386009471f0115ebf846232288338fae0d3e # Parent 9b1148aef5fad33787c248cd643d9d7bac5a4e9d Fixed recognition of the extension of certain JPG files. The 4th character may be anything between e0 and ef; the first 3 should be sufficient for a magic number, though a more 'complete' solution would verify that (e0 <= data[3] <= ef). Also, added recognition of TIF files (magic number: MM or II). Refs #725, which gave examples of several JPGs with (data[3] == e1). diff -r 9b1148aef5fa -r 0a4238600947 libpurple/util.c --- a/libpurple/util.c Tue Jun 05 07:06:09 2007 +0000 +++ b/libpurple/util.c Tue Jun 05 12:04:09 2007 +0000 @@ -2654,14 +2654,17 @@ if (len >= 4) { - if (!strncmp((char *)data, "BM", 2)) - return "bmp"; - else if (!strncmp((char *)data, "GIF8", 4)) + if (!strncmp((char *)data, "GIF8", 4)) return "gif"; - else if (!strncmp((char *)data, "\xff\xd8\xff\xe0", 4)) + else if (!strncmp((char *)data, "\xff\xd8\xff", 3)) /* 4th may be e0 through ef */ return "jpg"; else if (!strncmp((char *)data, "\x89PNG", 4)) return "png"; + else if (!strncmp((char *)data, "MM", 2) || + !strncmp((char *)data, "II", 2)) + return "tif"; + ekse if (!strncmp((char *)data, "BM", 2)) + return "bmp"; } return "icon";