From: Amos Jeffries Date: Sat, 25 Apr 2009 01:14:02 +0000 (+1200) Subject: Bug 2536: %H in error page ERR_DNS_FAIL is not filled on HTTPS X-Git-Tag: SQUID_3_0_STABLE15~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aae037b27ccdca6c887ea00e556a1aa92d8dd6c4;p=thirdparty%2Fsquid.git Bug 2536: %H in error page ERR_DNS_FAIL is not filled on HTTPS --- diff --git a/src/errorpage.cc b/src/errorpage.cc index 4e683d060f..57e75854b1 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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': diff --git a/src/protos.h b/src/protos.h index 71b0a92ee7..46de068294 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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); diff --git a/src/url.cc b/src/url.cc index 77c7e1f0db..1ed195fd3b 100644 --- a/src/url.cc +++ b/src/url.cc @@ -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: