From a102fa8748a836d031e2e0e263b58af8c855332f Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 1 Oct 2026 17:12:28 -1000 Subject: Keep the query string across the about redirects The hop to the trailing-slash form of the about page, and the hop back to the summary of a repository without a readme, were built from the path alone, so a request for the about page of another branch landed on the default one. The query goes into the Location line as the client sent it, with any byte a header cannot carry percent-encoded. --- tests/t0303-robustness.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index be98644..73c2ca5 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -507,6 +507,19 @@ test_expect_success 'the dumb transport withholds the alternates file' ' grep "^Status: 200" tmp ' +# The about page redirects to its trailing-slash form so relative links +# resolve, and the branch asked for has to survive that hop, as does the +# hop back to the summary of a repository without a readme. +test_expect_success 'the about redirects keep the query string' ' + git -C repos/rob branch other HEAD && + CGIT_CONFIG="$PWD/aboutrc" QUERY_STRING="url=rob/about&h=other&x=1" cgit >tmp && + grep "^Status: 301" tmp && + grep "^Location: /rob/about/?h=other&x=1$" tmp && + robq "url=rob/about/&h=other" >tmp && + grep "^Status: 302" tmp && + grep "^Location: /rob/about/../?h=other$" tmp +' + test_expect_success 'a symlink whose target is a large blob is listed without it' ' big=$(head -c 5000 /dev/zero | tr "\0" a | git -C repos/rob hash-object -w --stdin) && ( -- cgit v2.8.0