From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 3 Oct 2020 18:17:48 +0000 (+0200)
Subject: Lowercase the host name in functions that set it
X-Git-Tag: v_3_0_29~50
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/developer-manual/man-page/static/gitweb.js?a=commitdiff_plain;h=5981fdcc7bb9ddc21f7d974fdd4336ab0367dbe9;p=privoxy.git

Lowercase the host name in functions that set it

In case of get_destination_from_https_headers() it's important
to get stable hashes for certificates.

In case of get_destination_from_headers() and parse_http_url()
it's mainly cosmetic.
---

diff --git a/parsers.c b/parsers.c
index 3f704deb..eab5e76b 100644
--- a/parsers.c
+++ b/parsers.c
@@ -4587,7 +4587,11 @@ jb_err get_destination_from_headers(const struct list *headers, struct http_requ
       return JB_ERR_PARSE;
    }
 
-   p = strdup_or_die(host);
+   p = string_tolower(host);
+   if (p == NULL)
+   {
+      return JB_ERR_MEMORY;
+   }
    chomp(p);
    q = strdup_or_die(p);
 
@@ -4674,7 +4678,11 @@ jb_err get_destination_from_https_headers(const struct list *headers, struct htt
       return JB_ERR_PARSE;
    }
 
-   p = strdup_or_die(host);
+   p = string_tolower(host);
+   if (p == NULL)
+   {
+      return JB_ERR_MEMORY;
+   }
    chomp(p);
    q = strdup_or_die(p);
 
diff --git a/urlmatch.c b/urlmatch.c
index 4886e4c4..23a6b543 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -302,7 +302,7 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr
             url_path
          );
          *url_path = '\0';
-         http->hostport = strdup_or_die(url_noproto);
+         http->hostport = string_tolower(url_noproto);
       }
       else
       {
@@ -311,10 +311,15 @@ jb_err parse_http_url(const char *url, struct http_request *http, int require_pr
           * or CONNECT requests
           */
          http->path = strdup_or_die("/");
-         http->hostport = strdup_or_die(url_noproto);
+         http->hostport = string_tolower(url_noproto);
       }
 
       freez(buf);
+
+      if (http->hostport == NULL)
+      {
+         return JB_ERR_PARSE;
+      }
    }
 
    if (!host_available)