]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use the errorpage codes to generate a special URL with the %2f hack
authorwessels <>
Sun, 30 Nov 1997 10:08:37 +0000 (10:08 +0000)
committerwessels <>
Sun, 30 Nov 1997 10:08:37 +0000 (10:08 +0000)
for failed request (Henrik Nordstrom)

errors/English/ERR_FTP_FAILURE
src/errorpage.cc
src/ftp.cc
src/protos.h

index 74bef4c16f71afe297f8d5be5ad86a0c8923925c..5e5b36eae1eaed610efd61c40ec5f8261a13e5db 100644 (file)
@@ -17,3 +17,8 @@ and then received this reply
 <PRE><STRONG>
        %F
 </STRONG></PRE>
+<P>
+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 <A HREF="%B">%B</A>.
+
index a2735e69803d2c151b6edd5c9013c75c421f1639..e4a52599e486e82ec874a20d11299215f6e2f364 100644 (file)
@@ -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;
index 97c246cf7b75418b191f8c464b71f719dc55d37a..6d001880044d7039d1b6e73077dbbf4ccd5c364b 100644 (file)
@@ -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;
+}
index 8b3faf452175f56f05f4905f8cae58cd9fa9208e..ebaa4bfb13d27c064151627d893335962fff7ab7 100644 (file)
@@ -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 *);