[patch] strip_password strips too much



again affects FTPs with password. in this case, path doesn't show on the panel, only the hostname.
--
Jindrich Makovicka
Index: util.c
===================================================================
RCS file: /cvs/gnome/mc/src/util.c,v
retrieving revision 1.93
diff -u -b -B -r1.93 util.c
--- util.c	19 Feb 2003 00:42:04 -0000	1.93
+++ util.c	4 May 2003 20:11:13 -0000
@@ -410,9 +410,8 @@
 		     {"ftp://";, 6},
 		     {"/#smb:", 6},
     };
-    char *at, *inner_colon, *dir;
+    char *at, *inner_colon, *tmp;
     int i;
-    char *result = p;
     
     for (i = 0; i < sizeof (prefixes)/sizeof (prefixes[0]); i++) {
 	char *q;
@@ -421,27 +420,28 @@
 	    if((q = strstr (p, prefixes[i].name)) == 0)
 	       continue;
             else
-	        p = q + prefixes[i].len;
+	        tmp = q + prefixes[i].len;
+       	} else {
+	    tmp = p;
        	};
 
-        if ((dir = strchr (p, PATH_SEP)) != NULL)
-   	    *dir = '\0';
-        /* search for any possible user */
-        at = strchr (p, '@');
-
-        /* We have a username */
-        if (at) {
-            *at = 0;
-            inner_colon = strchr (p, ':');
-  	    *at = '@';
-            if (inner_colon)
-                strcpy (inner_colon, at);
+	inner_colon = 0;
+	at = 0;
+	while (*tmp) {
+	    if (*tmp == PATH_SEP) break; /* path sepaarator */
+	    if (*tmp == ':' && !inner_colon) inner_colon = tmp;
+	    if (*tmp == '@' && !at) {
+		at = tmp;
+		break;
         }
-        if (dir)
-	    *dir = PATH_SEP;
+	    tmp++;
+	}
+	if (at && inner_colon) {
+	    memmove(inner_colon, at, strlen(at)+1);
 	break;
     }
-    return (result);
+    }
+    return (p);
 }
 
 char *strip_home_and_password(const char *dir)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]