Index: squid/src/protos.h diff -c squid/src/protos.h:1.387.2.7 squid/src/protos.h:1.387.2.9 *** squid/src/protos.h:1.387.2.7 Sun Sep 9 13:59:28 2001 --- squid/src/protos.h Sat Feb 16 18:10:15 2002 *************** *** 1108,1114 **** #define strSet(s,ptr,ch) (s).buf[ptr-(s).buf] = (ch) #define strCut(s,pos) (((s).len = pos) , ((s).buf[pos] = '\0')) #define strCutPtr(s,ptr) (((s).len = (ptr)-(s).buf) , ((s).buf[(s).len] = '\0')) ! /* #define strCat(s,str) stringAppend(&(s), (str), strlen(str)+1) */ extern void stringInit(String * s, const char *str); extern void stringLimitInit(String * s, const char *str, int len); extern String stringDup(const String * s); --- 1108,1114 ---- #define strSet(s,ptr,ch) (s).buf[ptr-(s).buf] = (ch) #define strCut(s,pos) (((s).len = pos) , ((s).buf[pos] = '\0')) #define strCutPtr(s,ptr) (((s).len = (ptr)-(s).buf) , ((s).buf[(s).len] = '\0')) ! #define strCat(s,str) stringAppend(&(s), (str), strlen(str)) extern void stringInit(String * s, const char *str); extern void stringLimitInit(String * s, const char *str, int len); extern String stringDup(const String * s); Index: squid/src/ftp.c diff -c squid/src/ftp.c:1.298.2.5 squid/src/ftp.c:1.298.2.6 *** squid/src/ftp.c:1.298.2.5 Tue Sep 18 07:55:50 2001 --- squid/src/ftp.c Sat Feb 16 17:41:18 2002 *************** *** 88,95 **** int password_url; char *reply_hdr; int reply_hdr_state; ! char *title_url; ! char *base_href; int conn_att; int login_att; ftp_state_t state; --- 88,95 ---- int password_url; char *reply_hdr; int reply_hdr_state; ! String title_url; ! String base_href; int conn_att; int login_att; ftp_state_t state; *************** *** 298,305 **** safe_free(ftpState->old_request); safe_free(ftpState->old_reply); safe_free(ftpState->old_filepath); ! safe_free(ftpState->title_url); ! safe_free(ftpState->base_href); safe_free(ftpState->filepath); safe_free(ftpState->data.host); if (ftpState->data.fd > -1) { --- 298,305 ---- safe_free(ftpState->old_request); safe_free(ftpState->old_reply); safe_free(ftpState->old_filepath); ! stringClean(&ftpState->title_url); ! stringClean(&ftpState->base_href); safe_free(ftpState->filepath); safe_free(ftpState->data.host); if (ftpState->data.fd > -1) { *************** *** 361,371 **** storeAppendPrintf(e, "\n", mkrfc1123(squid_curtime)); storeAppendPrintf(e, "
\n");
--- 361,371 ----
storeAppendPrintf(e, "\n", mkrfc1123(squid_curtime));
storeAppendPrintf(e, "\n");
storeAppendPrintf(e, "FTP Directory: %s\n",
! html_quote(strBuf(ftpState->title_url)));
storeAppendPrintf(e, " \n");
if (ftpState->flags.use_base)
storeAppendPrintf(e, " \n",
! html_quote(strBuf(ftpState->base_href)));
storeAppendPrintf(e, "\n");
if (ftpState->cwd_message) {
storeAppendPrintf(e, "\n");
***************
*** 378,385 ****
storeAppendPrintf(e, "\n");
storeAppendPrintf(e, "FTP Directory: ");
/* "ftp://" == 6 characters */
! assert(strlen(ftpState->title_url) >= 6);
! title = html_quote(ftpState->title_url);
for (i = 6, j = 0; title[i]; j = i) {
storeAppendPrintf(e, "\n");
storeAppendPrintf(e, "FTP Directory: ");
/* "ftp://" == 6 characters */
! assert(strLen(ftpState->title_url) >= 6);
! title = html_quote(strBuf(ftpState->title_url));
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[k] != '/')
storeAppendPrintf(e, "%c", title[k++]);
storeAppendPrintf(e, "");
if (k < i)
--- 390,396 ----
storeAppendPrintf(e, "\">");
for (k = j; k < i - 1; k++)
storeAppendPrintf(e, "%c", title[k]);
! if (strBuf(ftpState->title_url)[k] != '/')
storeAppendPrintf(e, "%c", title[k++]);
storeAppendPrintf(e, "");
if (k < i)
***************
*** 398,405 ****
if (i == j) {
/* Error guard, or "assert" */
storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n",
! html_quote(ftpState->title_url));
! debug(9, 0) ("Failed to parse URL: %s\n", ftpState->title_url);
break;
}
}
--- 398,405 ----
if (i == j) {
/* Error guard, or "assert" */
storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n",
! html_quote(strBuf(ftpState->title_url)));
! debug(9, 0) ("Failed to parse URL: %s\n", strBuf(ftpState->title_url));
break;
}
}
***************
*** 999,1036 ****
ftpBuildTitleUrl(FtpStateData * ftpState)
{
request_t *request = ftpState->request;
! size_t len;
! char *t;
! len = 64
! + strlen(ftpState->user)
! + strlen(ftpState->password)
! + strlen(request->host)
! + strLen(request->urlpath);
! t = ftpState->title_url = xcalloc(len, 1);
! strcat(t, "ftp://");
if (strcmp(ftpState->user, "anonymous")) {
! strcat(t, ftpState->user);
! strcat(t, "@");
}
! strcat(t, request->host);
! if (request->port != urlDefaultPort(PROTO_FTP))
! snprintf(&t[strlen(t)], len - strlen(t), ":%d", request->port);
! strcat(t, strBuf(request->urlpath));
! t = ftpState->base_href = xcalloc(len, 1);
! strcat(t, "ftp://");
if (strcmp(ftpState->user, "anonymous")) {
! strcat(t, rfc1738_escape_part(ftpState->user));
if (ftpState->password_url) {
! strcat(t, ":");
! strcat(t, rfc1738_escape_part(ftpState->password));
}
! strcat(t, "@");
}
! strcat(t, request->host);
! if (request->port != urlDefaultPort(PROTO_FTP))
! snprintf(&t[strlen(t)], len - strlen(t), ":%d", request->port);
! strcat(t, strBuf(request->urlpath));
! strcat(t, "/");
}
void
--- 999,1033 ----
ftpBuildTitleUrl(FtpStateData * ftpState)
{
request_t *request = ftpState->request;
!
! stringReset(&ftpState->title_url, "ftp://");
if (strcmp(ftpState->user, "anonymous")) {
! strCat(ftpState->title_url, ftpState->user);
! strCat(ftpState->title_url, "@");
! }
! strCat(ftpState->title_url, request->host);
! if (request->port != urlDefaultPort(PROTO_FTP)) {
! strCat(ftpState->title_url, ":");
! strCat(ftpState->title_url, xitoa(request->port));
}
! strCat(ftpState->title_url, strBuf(request->urlpath));
!
! stringReset(&ftpState->base_href, "ftp://");
if (strcmp(ftpState->user, "anonymous")) {
! strCat(ftpState->base_href, rfc1738_escape_part(ftpState->user));
if (ftpState->password_url) {
! strCat(ftpState->base_href, ":");
! strCat(ftpState->base_href, rfc1738_escape_part(ftpState->password));
! }
! strCat(ftpState->base_href, "@");
}
! strCat(ftpState->base_href, request->host);
! if (request->port != urlDefaultPort(PROTO_FTP)) {
! strCat(ftpState->base_href, ":");
! strCat(ftpState->base_href, xitoa(request->port));
}
! strCat(ftpState->base_href, strBuf(request->urlpath));
! strCat(ftpState->base_href, "/");
}
void
***************
*** 1577,1583 ****
{
if (!ftpState->flags.isdir) {
debug(9, 3) ("Directory path did not end in /\n");
! strcat(ftpState->title_url, "/");
ftpState->flags.isdir = 1;
ftpState->flags.use_base = 1;
}
--- 1574,1580 ----
{
if (!ftpState->flags.isdir) {
debug(9, 3) ("Directory path did not end in /\n");
! strCat(ftpState->title_url, "/");
ftpState->flags.isdir = 1;
ftpState->flags.use_base = 1;
}
***************
*** 1634,1640 ****
if (ftpState->size == 0) {
debug(9, 2) ("ftpReadSize: SIZE reported %s on %s\n",
ftpState->ctrl.last_reply,
! ftpState->title_url);
ftpState->size = -1;
}
} else if (code < 0) {
--- 1631,1637 ----
if (ftpState->size == 0) {
debug(9, 2) ("ftpReadSize: SIZE reported %s on %s\n",
ftpState->ctrl.last_reply,
! strBuf(ftpState->title_url));
ftpState->size = -1;
}
} else if (code < 0) {