From: wessels <> Date: Tue, 12 Jan 1999 03:05:50 +0000 (+0000) Subject: Small change of Squid output for FTP X-Git-Tag: SQUID_3_0_PRE1~2440 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e5ae4a4f3314309a6e851cf295e157e40aab01c;p=thirdparty%2Fsquid.git Small change of Squid output for FTP Henrik Nordstrom Andrew Filonov --- diff --git a/src/ftp.cc b/src/ftp.cc index 340538afea..839a318395 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.258 1999/01/08 21:12:11 wessels Exp $ + * $Id: ftp.cc,v 1.259 1999/01/11 20:05:50 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -339,6 +339,7 @@ ftpListingStart(FtpStateData * ftpState) StoreEntry *e = ftpState->entry; wordlist *w; char *dirup; + int i, j, k; storeBuffer(e); storeAppendPrintf(e, "\n", version_string); @@ -360,7 +361,32 @@ ftpListingStart(FtpStateData * ftpState) wordlistDestroy(&ftpState->cwd_message); } storeAppendPrintf(e, "

\n"); - storeAppendPrintf(e, "FTP Directory: %s\n", ftpState->title_url); + storeAppendPrintf(e, "FTP Directory: "); + /* "ftp://" == 6 characters */ + assert(strlen(ftpState->title_url) >= 6); + for (i = 6, j = 0; ftpState->title_url[i]; j = i) { + storeAppendPrintf(e, "title_url[i], "/"); + if (ftpState->title_url[i] == '/') + i++; + for (k = 0; k < i; k++) + storeAppendPrintf(e, "%c", ftpState->title_url[k]); + storeAppendPrintf(e, "\">"); + for (k = j; k < i - 1; k++) + storeAppendPrintf(e, "%c", ftpState->title_url[k]); + if (ftpState->title_url[k] != '/') + storeAppendPrintf(e, "%c", ftpState->title_url[k++]); + storeAppendPrintf(e, ""); + if (k < i) + storeAppendPrintf(e, "%c", ftpState->title_url[k++]); + if (i == j) { + /* Error guard, or "assert" */ + storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n", + ftpState->title_url); + debug(9, 0) ("Failed to parse URL: %s\n", ftpState->title_url); + break; + } + } storeAppendPrintf(e, "

\n"); storeAppendPrintf(e, "
\n");
     dirup = ftpHtmlifyListEntry("", ftpState);
@@ -1366,11 +1392,14 @@ ftpReadType(FtpStateData * ftpState)
 {
     int code = ftpState->ctrl.replycode;
     char *path;
-    char *d;
+    char *d, *p;
     debug(9, 3) ("This is ftpReadType\n");
     if (code == 200) {
 	path = xstrdup(strBuf(ftpState->request->urlpath));
-	for (d = strtok(path, "/"); d; d = strtok(NULL, "/")) {
+	for (d = p = path; *p; d = p) {
+	    p += strcspn(p, "/");
+	    if (*p)
+		*p++ = '\0';
 	    rfc1738_unescape(d);
 	    wordlistAdd(&ftpState->pathcomps, d);
 	}
@@ -1423,7 +1452,10 @@ ftpSendCwd(FtpStateData * ftpState)
     } else {
 	ftpState->flags.no_dotdot = 0;
     }
-    snprintf(cbuf, 1024, "CWD %s\r\n", path);
+    if (*path)
+	snprintf(cbuf, 1024, "CWD %s\r\n", path);
+    else
+	snprintf(cbuf, 1024, "CWD\r\n");
     ftpWriteCommand(cbuf, ftpState);
     ftpState->state = SENT_CWD;
 }
@@ -2077,7 +2109,6 @@ ftpTryDatachannelHack(FtpStateData * ftpState)
     ftpState->flags.tried_nlst = 0;
     /* And off we go */
     if (ftpState->flags.isdir) {
-	safe_free(ftpState->filepath);
 	ftpListDir(ftpState);
     } else {
 	ftpGetFile(ftpState);