From: Fabian Keil <fk@fabiankeil.de>
Date: Tue, 5 Jan 2021 13:32:50 +0000 (+0100)
Subject: sed(): Don't call enforce_header_order() if a filter removed the request line
X-Git-Tag: v_3_0_30~147
X-Git-Url: http://www.privoxy.org/gitweb/@default-cgi@/faq/@proxy-info-url@?a=commitdiff_plain;h=ff3493f08f35e907620bc9d56ba202d7e1300a68;p=privoxy.git

sed(): Don't call enforce_header_order() if a filter removed the request line

... as enforce_header_order() asserts that the request line is present.

Without the request line the request will be rejected as invalid
later on anyway, so sorting the headers first is pointless.
---

diff --git a/parsers.c b/parsers.c
index d63647d8..ba151d15 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1291,7 +1291,9 @@ jb_err sed(struct client_state *csp, int filter_server_headers)
       f++;
    }
 
-   if (!filter_server_headers && !list_is_empty(csp->config->ordered_client_headers))
+   if (!filter_server_headers &&
+       !list_is_empty(csp->config->ordered_client_headers) &&
+       csp->headers->first->str != NULL)
    {
       enforce_header_order(csp->headers, csp->config->ordered_client_headers);
    }