From 8f872bb65d5eb59e4abb16ea3068d78b5494a8d4 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Sun, 30 Nov 1997 10:08:37 +0000 Subject: [PATCH] Use the errorpage codes to generate a special URL with the %2f hack for failed request (Henrik Nordstrom) --- errors/English/ERR_FTP_FAILURE | 5 +++++ src/errorpage.cc | 6 +++++- src/ftp.cc | 31 ++++++++++++++++++++++++++++++- src/protos.h | 1 + 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/errors/English/ERR_FTP_FAILURE b/errors/English/ERR_FTP_FAILURE index 74bef4c16f..5e5b36eae1 100644 --- a/errors/English/ERR_FTP_FAILURE +++ b/errors/English/ERR_FTP_FAILURE @@ -17,3 +17,8 @@ and then received this reply

 	%F
 
+

+This might be caused by an FTP URL with an absolute path (which does +not comply with RFC 1738). If this is the cause, then the file +can be found at %B. + diff --git a/src/errorpage.cc b/src/errorpage.cc index a2735e6980..e4a52599e4 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.105 1997/11/24 18:27:15 wessels Exp $ + * $Id: errorpage.cc,v 1.106 1997/11/30 03:08:37 wessels Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -188,6 +188,7 @@ errorStateFree(ErrorState * err) #define CVT_BUF_SZ 512 /* + * B - URL with FTP %2f hack x * c - Squid error code * d - seconds elapsed since request received * e - errno x @@ -218,6 +219,9 @@ errorConvert(char token, ErrorState * err) static char buf[CVT_BUF_SZ]; const char *p = buf; switch (token) { + case 'B': + p = r ? ftpUrlWith2f(r) : "[no URL]"; + break; case 'e': snprintf(buf, CVT_BUF_SZ, "%d", err->xerrno); break; diff --git a/src/ftp.cc b/src/ftp.cc index 97c246cf7b..6d00188004 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,5 +1,5 @@ /* - * $Id: ftp.cc,v 1.174 1997/11/24 18:27:16 wessels Exp $ + * $Id: ftp.cc,v 1.175 1997/11/30 03:08:38 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1784,3 +1784,32 @@ ftpAuthRequired(const request_t * request, const char *realm) l += snprintf(buf + l, s - l, "\r\n%s", content); return buf; } + +char * +ftpUrlWith2f(const request_t * request) +{ + LOCAL_ARRAY(char, buf, MAX_URL); + LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1); + LOCAL_ARRAY(char, portbuf, 32); + char *t; + portbuf[0] = '\0'; + if (request->port != urlDefaultPort(request->protocol)) + snprintf(portbuf, 32, ":%d", request->port); + loginbuf[0] = '\0'; + if (strlen(request->login) > 0) { + strcpy(loginbuf, request->login); + if ((t = strchr(loginbuf, ':'))) + *t = '\0'; + strcat(loginbuf, "@"); + } + snprintf(buf, MAX_URL, "%s://%s%s%s%s%s", + ProtocolStr[request->protocol], + loginbuf, + request->host, + portbuf, + "/%2f", + request->urlpath); + if ((t = strchr(buf, '?'))) + *t = '\0'; + return buf; +} diff --git a/src/protos.h b/src/protos.h index 8b3faf4521..ebaa4bfb13 100644 --- a/src/protos.h +++ b/src/protos.h @@ -179,6 +179,7 @@ extern void fqdncacheFreeMemory(void); extern void fqdncache_restart(void); extern void ftpStart(request_t * req, StoreEntry * entry); +extern char *ftpUrlWith2f(const request_t *); extern void gopherStart(StoreEntry *); extern int gopherCachable(const char *); -- 2.47.3