]> granicus.if.org Git - transmission/commitdiff
(trunk gtk) #3971 "favicons do not work for IP addresses" -- fixed.
authorJordan Lee <jordan@transmissionbt.com>
Tue, 1 Feb 2011 01:38:58 +0000 (01:38 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Tue, 1 Feb 2011 01:38:58 +0000 (01:38 +0000)
gtr_get_host_from_url() wasn't written to handle dotted-quad or IPv6 address strings, but can handle them now.

gtk/filter.c
gtk/util.c

index c230ab0eff78b2135fc18404e0ccf77060f27df9..27109d9f09be9fc775b35580a9d0619689123b6b 100644 (file)
@@ -70,10 +70,12 @@ get_name_from_host( const char * host )
     char * name;
     const char * dot = strrchr( host, '.' );
 
-    if( dot == NULL )
+    if( tr_addressIsIP( host ) )
         name = g_strdup( host );
-    else
+    else if( dot )
         name = g_strndup( host, dot - host );
+    else
+        name = g_strdup( host );
 
     *name = g_ascii_toupper( *name );
 
index 1e09f7c3975aba0bd5ad4918846021be597fad18..e5333c79b9dea9dbbc25d56e2eb029c21cbf9125 100644 (file)
@@ -253,17 +253,19 @@ gtr_get_host_from_url( const char * url )
 {
     char * h = NULL;
     char * name;
-    const char * first_dot;
-    const char * last_dot;
 
     tr_urlParse( url, -1, NULL, &h, NULL, NULL );
-    first_dot = strchr( h, '.' );
-    last_dot = strrchr( h, '.' );
 
-    if( ( first_dot ) && ( last_dot ) && ( first_dot != last_dot ) )
-        name = g_strdup( first_dot + 1 );
-    else
+    if( tr_addressIsIP( h ) )
         name = g_strdup( h );
+    else {
+        const char * first_dot = strchr( h, '.' );
+        const char * last_dot = strrchr( h, '.' );
+        if( ( first_dot ) && ( last_dot ) && ( first_dot != last_dot ) )
+            name = g_strdup( first_dot + 1 );
+        else
+            name = g_strdup( h );
+    }
 
     tr_free( h );
     return name;