Make CGI_PREFIX protocol-relative when building with FEATURE_HTTPS_INSPECTION
authorFabian Keil <fk@fabiankeil.de>
Sat, 12 Dec 2020 22:49:22 +0000 (23:49 +0100)
committerFabian Keil <fk@fabiankeil.de>
Mon, 14 Dec 2020 07:49:17 +0000 (08:49 +0100)
This unbreaks (at least) https://config.privoxy.org/client-tags whose
buttons would previously use a http:// URL resulting in browser warnings.

Add and use new CGI_PREFIX_HTTP define in the one case we actually
need a http:// URL.

cgi.c
project.h

diff --git a/cgi.c b/cgi.c
index 94f6875..e03084e 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -457,7 +457,7 @@ static int referrer_is_safe(const struct client_state *csp)
       log_error(LOG_LEVEL_ERROR, "Denying access to %s. No referrer found.",
          csp->http->url);
    }
-   else if ((0 == strncmp(referrer, CGI_PREFIX, sizeof(CGI_PREFIX)-1))
+   else if ((0 == strncmp(referrer, CGI_PREFIX_HTTP, sizeof(CGI_PREFIX_HTTP)-1))
 #ifdef FEATURE_HTTPS_INSPECTION
          || (0 == strncmp(referrer, CGI_PREFIX_HTTPS, sizeof(CGI_PREFIX_HTTPS)-1))
          || (0 == strncmp(referrer, alt_prefix_https, strlen(alt_prefix_https)))
index ec3c155..e07c761 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1645,8 +1645,13 @@ struct configuration_spec
  * The prefix for CGI pages.  Written out in generated HTML.
  * INCLUDES the trailing slash.
  */
+#ifdef FEATURE_HTTPS_INSPECTION
+#define CGI_PREFIX  "//" CGI_SITE_2_HOST CGI_SITE_2_PATH "/"
+#define CGI_PREFIX_HTTPS "https:" CGI_PREFIX
+#else
 #define CGI_PREFIX  "http://" CGI_SITE_2_HOST CGI_SITE_2_PATH "/"
-#define CGI_PREFIX_HTTPS "https://" CGI_SITE_2_HOST CGI_SITE_2_PATH "/"
+#endif
+#define CGI_PREFIX_HTTP  "http://" CGI_SITE_2_HOST CGI_SITE_2_PATH "/"
 
 #endif /* ndef PROJECT_H_INCLUDED */