]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2536: %H in error page ERR_DNS_FAIL is not filled on HTTPS
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 25 Apr 2009 01:14:02 +0000 (13:14 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 25 Apr 2009 01:14:02 +0000 (13:14 +1200)
src/errorpage.cc
src/protos.h
src/url.cc

index 4e683d060fb67cc837df4367654aa8dba3466f3b..57e75854b12df50db390984d5c31d71759a803f6 100644 (file)
@@ -450,7 +450,7 @@ errorSend(int fd, ErrorState * err)
  *            to the client socket.
  *
  * Note:      If there is a callback, the callback is responsible for
- *            closeing the FD, otherwise we do it ourseves.
+ *            closing the FD, otherwise we do it ourseves.
  */
 static void
 errorSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data)
@@ -522,7 +522,7 @@ errorDump(ErrorState * err, MemBuf * mb)
     /* - IP stuff */
     str.Printf("ClientIP: %s\r\n", inet_ntoa(err->src_addr));
 
-    if (r && r->hier.host) {
+    if (r && r->hier.host[0] != '\0') {
         str.Printf("ServerIP: %s\r\n", r->hier.host);
     }
 
@@ -669,12 +669,11 @@ errorConvert(char token, ErrorState * err)
 
     case 'h':
         mb.Printf("%s", getMyHostname());
-
         break;
 
     case 'H':
         if (r) {
-            if (r->hier.host)
+            if (r->hier.host[0] != '\0') // if non-empty string.
                 p = r->hier.host;
             else
                 p = r->host;
@@ -689,7 +688,7 @@ errorConvert(char token, ErrorState * err)
         break;
 
     case 'I':
-        if (r && r->hier.host) {
+        if (r && r->hier.host[0] != '\0') // if non-empty string
             mb.Printf("%s", r->hier.host);
         } else
             p = "[unknown]";
@@ -784,7 +783,9 @@ errorConvert(char token, ErrorState * err)
         break;
 
     case 'U':
-        p = r ? urlCanonicalClean(r) : err->url ? err->url : "[no URL]";
+        /* Using the fake-https version of canonical so error pages see https:// */
+        /* even when the url-path cannot be shown as more than '*' */
+        p = r ? urlCanonicalFakeHttps(r) : err->url ? err->url : "[no URL]";
         break;
 
     case 'u':
index 71b0a92ee70fa210623689fdf31c401e94b5491b..46de0682941f678573a8f55135c0579b3c609743 100644 (file)
@@ -630,12 +630,13 @@ SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL);
 SQUIDCEXTERN void urlInitialize(void);
 SQUIDCEXTERN HttpRequest *urlParse(method_t, char *, HttpRequest *request = NULL);
 SQUIDCEXTERN const char *urlCanonical(HttpRequest *);
+SQUIDCEXTERN char *urlCanonicalClean(const HttpRequest *);
+SQUIDCEXTERN const char *urlCanonicalFakeHttps(const HttpRequest * request);
 SQUIDCEXTERN char *urlRInternal(const char *host, u_short port, const char *dir, const char *name);
 SQUIDCEXTERN char *urlInternal(const char *dir, const char *name);
 SQUIDCEXTERN int matchDomainName(const char *host, const char *domain);
 SQUIDCEXTERN int urlCheckRequest(const HttpRequest *);
 SQUIDCEXTERN int urlDefaultPort(protocol_t p);
-SQUIDCEXTERN char *urlCanonicalClean(const HttpRequest *);
 SQUIDCEXTERN char *urlHostname(const char *url);
 SQUIDCEXTERN void urlExtMethodConfigure(void);
 
index 77c7e1f0dbcaef11b31585c07eb9bd072f93cf93..1ed195fd3b5471a9de522c65baea191914de0f95 100644 (file)
@@ -436,6 +436,28 @@ urlCanonicalClean(const HttpRequest * request)
     return buf;
 }
 
+/**
+ * Yet another alternative to urlCanonical.
+ * This one addes the https:// parts to METHOD_CONNECT URL
+ * for use in error page outputs.
+ * Luckily we can leverage the others instead of duplicating.
+ */
+const char *
+urlCanonicalFakeHttps(const HttpRequest * request)
+{
+    LOCAL_ARRAY(char, buf, MAX_URL);
+
+    // method CONNECT and port HTTPS
+    if(request->method == METHOD_CONNECT && request->port == 443) {
+        snprintf(buf, MAX_URL, "https://%s/*", request->GetHost());
+        return buf;
+    }
+
+    // else do the normal complete canonical thing.
+    return urlCanonicalClean(request);
+}
+
+
 /*
  * matchDomainName() compares a hostname with a domainname according
  * to the following rules: