From 26a9ac5f2f34ff9fd030004a490add53fc6db766 Mon Sep 17 00:00:00 2001 From: Paul Barnetta Date: Tue, 17 Jan 2023 09:44:11 +1100 Subject: [PATCH] BUG/MINOR: mux-fcgi: Correctly set pathinfo Existing logic for checking whether a regex subexpression for pathinfo is matched results in valid matches being ignored and non-matches having a new zero length string stored in params->pathinfo. This patch reverses the logic so params->pathinfo is set when the subexpression is matched. Without this patch the example configuration in the documentation: path-info ^(/.+\.php)(/.*)?$ does not result in PATH_INFO being sent to the FastCGI application, as expected, when the second subexpression is matched (in which case both pmatch[2].rm_so and pmatch[2].rm_eo will be non-negative integers). This patch may be backported as far as 2.2, the first release that made the capture of this second subexpression optional. --- src/mux_fcgi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 597fbcbbd..9b4827174 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -1308,7 +1308,7 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst * captured */ params->scriptname = ist2(path.ptr + pmatch[1].rm_so, pmatch[1].rm_eo - pmatch[1].rm_so); - if (!(params->mask & FCGI_SP_PATH_INFO) && (pmatch[2].rm_so == -1 || pmatch[2].rm_eo == -1)) + if (!(params->mask & FCGI_SP_PATH_INFO) && !(pmatch[2].rm_so == -1 || pmatch[2].rm_eo == -1)) params->pathinfo = ist2(path.ptr + pmatch[2].rm_so, pmatch[2].rm_eo - pmatch[2].rm_so); check_index: