changeset 154:d6ecbdee0afa

fixed a bug around strchr() pointed out by mojin.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 25 Jul 2008 18:39:19 +0900
parents 07cedffb1c63
children 0921655b4ae1
files pidgin-twitter.c
diffstat 1 files changed, 11 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Fri Jul 25 16:53:43 2008 +0900
+++ b/pidgin-twitter.c	Fri Jul 25 18:39:19 2008 +0900
@@ -1750,26 +1750,17 @@
     gchar *tmp = g_strdup_printf("%s/%s", url,
                                  purple_url_encode(slash+1));
 
-    gchar *startp = slash + 1;
-    gchar *ext = NULL;
-    do {
-        ext = strchr(startp, '.');
-        if(ext) {
-            if(!strcasecmp(ext, ".jpg") || !strcasecmp(ext, ".jpeg")) {
-                data->img_type = "jpg";
-                break;
-            }
-            else if(!strcasecmp(ext, ".png")) {
-                data->img_type = "png";
-                break;
-            }
-            else if(!strcasecmp(ext, ".gif")) {
-                data->img_type = "gif";
-                break;
-            }
-            startp = ext;
-        }
-    } while(ext);
+
+    gchar *lower = g_ascii_strdown(slash+1, -1);
+
+    if(strstr(lower, ".png"))
+        data->img_type = "png";
+    else if(strstr(lower, ".gif"))
+        data->img_type = "gif";
+    else if(strstr(lower, ".jpg") || strstr(lower, ".jpeg"))
+        data->img_type = "jpg";
+
+    g_free(lower);
 
     g_free(url);
     url = tmp;