changeset 309:e922ad73c07e

wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 02 Jul 2009 05:54:58 +0900
parents bc7d8baf79dd
children aa1f0dd1a723
files icon.c
diffstat 1 files changed, 11 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/icon.c	Thu Jul 02 05:15:43 2009 +0900
+++ b/icon.c	Thu Jul 02 05:54:58 2009 +0900
@@ -5,10 +5,10 @@
 extern GRegex *regp[];
 
 static gchar *ext_list[] = {
-    "png",
-    "gif",
-    "jpg",
-    "bmp",
+    ".png",
+    ".gif",
+    ".jpg",
+    ".bmp",
     NULL
 };
 
@@ -445,20 +445,17 @@
     gchar *lower = g_ascii_strdown(purple_url_decode(slash+1), -1);
 
     gchar **extp;
-    gchar *dot;
     data->img_type = NULL;
 
-    dot = strrchr(lower, '.');
-    if(dot) {
-        for(extp = ext_list; *extp; extp++) {
-            if(!strcmp(dot+1, *extp)) {
-                data->img_type = *extp;
-                break;
-            }
+    for(extp = ext_list; *extp; extp++) {
+        if(g_strrstr(lower, *extp)) {
+            data->img_type = *extp+1;
+            break;
         }
-        if(!data->img_type && !strcmp(dot+1, "jpeg"))
-            data->img_type = ext_list[2]; /* jpg */
     }
+    if(!data->img_type && g_strrstr(lower, ".jpeg"))
+        data->img_type = ext_list[2]+1; /* jpg */
+
     g_free(lower);
 
     /* return if no suitable image found */