From: serassio <> Date: Sun, 26 Jun 2005 23:12:47 +0000 (+0000) Subject: Bug #1220: Title in FTP listings somewhat messed up X-Git-Tag: SQUID_3_0_PRE4~720 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7505774d0d66b25e766febb6cbdea8553af75505;p=thirdparty%2Fsquid.git Bug #1220: Title in FTP listings somewhat messed up Show FTP URLs in decoded form to allow for national characters etc to be displayed in a sane manner. Forward port of 2.5 patch. --- diff --git a/src/ftp.cc b/src/ftp.cc index f16bb74c0d..0efcd00e31 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.362 2005/05/01 08:11:48 serassio Exp $ + * $Id: ftp.cc,v 1.363 2005/06/26 17:12:47 serassio Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -472,15 +472,20 @@ ftpListingStart(FtpStateData * ftpState) wordlist *w; char *dirup; int i, j, k; - char *title; + const char *title = ftpState->title_url.buf(); storeBuffer(e); storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "\n", version_string); storeAppendPrintf(e, "\n", mkrfc1123(squid_curtime)); storeAppendPrintf(e, "\n"); - storeAppendPrintf(e, "FTP Directory: %s\n", - html_quote(ftpState->title_url.buf())); + { + char *t = xstrdup(title); + rfc1738_unescape(t); + storeAppendPrintf(e, "FTP Directory: %s\n", html_quote(t)); + xfree(t); + } + storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "\n"); @@ -507,36 +512,34 @@ ftpListingStart(FtpStateData * ftpState) storeAppendPrintf(e, "FTP Directory: "); /* "ftp://" == 6 characters */ assert(ftpState->title_url.size() >= 6); - title = html_quote(ftpState->title_url.buf()); + k = 6 + strcspn(&title[6], "/"); for (i = 6, j = 0; title[i]; j = i) { storeAppendPrintf(e, ""); - - for (k = j; k < i - 1; k++) - storeAppendPrintf(e, "%c", title[k]); - - if (ftpState->title_url.buf()[k] != '/') - storeAppendPrintf(e, "%c", title[k++]); + if (i > j) { + char *url = xstrdup(title); + url[i] = '\0'; + storeAppendPrintf(e, "%s", html_quote(url + k)); + storeAppendPrintf(e, "/"); + storeAppendPrintf(e, "\">"); + rfc1738_unescape(url + j); + storeAppendPrintf(e, "%s", html_quote(url + j)); + safe_free(url); + storeAppendPrintf(e, ""); + } - storeAppendPrintf(e, ""); + storeAppendPrintf(e, "/"); - if (k < i) - storeAppendPrintf(e, "%c", title[k++]); + if (title[i] == '/') + i++; if (i == j) { /* Error guard, or "assert" */ storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n", - html_quote(ftpState->title_url.buf())); - debug(9, 0) ("Failed to parse URL: %s\n", ftpState->title_url.buf()); + html_quote(title)); + debug(9, 0) ("Failed to parse URL: %s\n", title); break; } }