From: serassio <> Date: Thu, 15 Sep 2005 18:55:44 +0000 (+0000) Subject: Forward port of old 2.5 missing changes: X-Git-Tag: SQUID_3_0_PRE4~618 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80dc929dd9317532af1637fd3adbf334cd3896aa;p=thirdparty%2Fsquid.git Forward port of old 2.5 missing changes: - Cosmetic cleanup of how // is handled within FTP URL-paths - Clean up use of BASE HREF in ftp listings, mainly in ;type=d format listings. - Bug #1253: BASE HREF missing on ftp directory URLs without / --- diff --git a/src/ftp.cc b/src/ftp.cc index a0f1b31d94..74f1a05b7a 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.369 2005/09/15 10:43:13 serassio Exp $ + * $Id: ftp.cc,v 1.370 2005/09/15 12:55:44 serassio Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -559,7 +559,8 @@ ftpListingFinish(FtpStateData * ftpState) if (ftpState->flags.listformat_unknown && !ftpState->flags.tried_nlst) { storeAppendPrintf(e, "[As plain directory]\n"); } else if (ftpState->typecode == 'D') { - storeAppendPrintf(e, "[As extended directory]\n"); + const char *path = ftpState->filepath ? ftpState->filepath : "."; + storeAppendPrintf(e, "[As extended directory]\n", html_quote(path)); } storeAppendPrintf(e, "
\n"); @@ -1287,21 +1288,19 @@ ftpCheckUrlpath(FtpStateData * ftpState) } l = request->urlpath.size(); - ftpState->flags.need_base_href = 1; /* check for null path */ if (!l) { ftpState->flags.isdir = 1; ftpState->flags.root_dir = 1; + ftpState->flags.need_base_href = 1; /* Work around broken browsers */ } else if (!request->urlpath.cmp("/%2f/")) { /* UNIX root directory */ - ftpState->flags.need_base_href = 0; ftpState->flags.isdir = 1; ftpState->flags.root_dir = 1; } else if ((l >= 1) && (*(request->urlpath.buf() + l - 1) == '/')) { /* Directory URL, ending in / */ ftpState->flags.isdir = 1; - ftpState->flags.need_base_href = 0; if (l == 1) ftpState->flags.root_dir = 1; @@ -1879,7 +1878,8 @@ ftpReadType(FtpStateData * ftpState) rfc1738_unescape(d); - wordlistAdd(&ftpState->pathcomps, d); + if (*d) + wordlistAdd(&ftpState->pathcomps, d); } xfree(path); @@ -1940,10 +1940,7 @@ ftpSendCwd(FtpStateData * ftpState) ftpState->flags.no_dotdot = 0; } - if (*path) - snprintf(cbuf, 1024, "CWD %s\r\n", path); - else - snprintf(cbuf, 1024, "CWD\r\n"); + snprintf(cbuf, 1024, "CWD %s\r\n", path); ftpWriteCommand(cbuf, ftpState); @@ -2450,7 +2447,6 @@ ftpRestOrList(FtpStateData * ftpState) if (ftpState->typecode == 'D') { ftpState->flags.isdir = 1; - ftpState->flags.need_base_href = 1; if (ftpState->flags.put) { ftpSendMkdir(ftpState); /* PUT name;type=d */ @@ -2574,7 +2570,6 @@ static void ftpSendList(FtpStateData * ftpState) { if (ftpState->filepath) { - ftpState->flags.need_base_href = 1; snprintf(cbuf, 1024, "LIST %s\r\n", ftpState->filepath); } else { snprintf(cbuf, 1024, "LIST\r\n"); @@ -2590,7 +2585,6 @@ ftpSendNlst(FtpStateData * ftpState) ftpState->flags.tried_nlst = 1; if (ftpState->filepath) { - ftpState->flags.need_base_href = 1; snprintf(cbuf, 1024, "NLST %s\r\n", ftpState->filepath); } else { snprintf(cbuf, 1024, "NLST\r\n");