From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 12 Dec 2020 22:49:22 +0000 (+0100)
Subject: Make CGI_PREFIX protocol-relative when building with FEATURE_HTTPS_INSPECTION
X-Git-Tag: v_3_0_30~270^2~28
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/@default-cgi@/faq/static/@default-cgi@send-stylesheet?a=commitdiff_plain;h=373171c5f8ab7bfd36ec555e9fa63403f553cdfa;p=privoxy.git

Make CGI_PREFIX protocol-relative when building with FEATURE_HTTPS_INSPECTION

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.
---

diff --git a/cgi.c b/cgi.c
index 94f6875f..e03084e0 100644
--- 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)))
diff --git a/project.h b/project.h
index ec3c1559..e07c7616 100644
--- 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 */