From cdced75c1d430fea5e88365d3e6c1b3390f58bb8 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 8 Oct 2026 20:51:23 -1000 Subject: Encode repository urls and the feed branch Links built from the repository url, among them the description link on the index and the Atom and refs links, wrote it as configured, so a name holding a space, '#' or '?' broke them. The feed link in the page head did the same with the branch, which turned a '+' into a space. --- tests/t0101-index.sh | 10 ++++++++-- tests/t0303-robustness.sh | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index b2ec813..adad6be 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -16,8 +16,8 @@ test_expect_success 'find foo description' 'grep "\[no description\]" tmp' test_expect_success 'find bar repo' 'grep "bar" tmp' test_expect_success 'find bar description' 'grep "the bar repo" tmp' test_expect_success 'find foo+bar repo' 'grep ">foo+bar<" tmp' -test_expect_success 'verify foo+bar link' 'grep "/foo+bar/" tmp' -test_expect_success 'verify "with%20space" link' 'grep "/with%20space/" tmp' +test_expect_success 'verify foo+bar links' 'test $(grep -o "href=./foo%2Bbar/." tmp | wc -l) = 2' +test_expect_success 'verify "with%20space" links' 'test $(grep -o "href=./with%20space/." tmp | wc -l) = 2' test_expect_success 'no tree-link' '! grep "foo/tree" tmp' test_expect_success 'no log-link' '! grep "foo/log" tmp' @@ -47,4 +47,10 @@ test_expect_success 'each css and js entry gets a link of its own' ' grep "/b.js" scripts ' +test_expect_success 'the feed link encodes the repository and the branch' ' + sed "s/^cache-size=.*/cache-size=0/" cgitrc >feedrc && + CGIT_CONFIG="$PWD/feedrc" HTTP_HOST=example.org QUERY_STRING="url=foo%2Bbar/log/&h=1%2B2" cgit >tmp && + grep "title=.Atom feed. href=.http://example.org/foo%2Bbar/atom/?h=1%2B2." tmp +' + test_done diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 6e8f0c0..6c53dbe 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -639,6 +639,12 @@ test_expect_success 'the about redirect keeps the query string' ' grep "^Status: 200" tmp ' +test_expect_success 'the about redirect encodes the repository url once' ' + cgit_url "foo%2Bbar/about/" >tmp && + grep "^Status: 302" tmp && + grep "^Location: /foo%2Bbar/$" tmp +' + # The about page shows the readme alone and its links lead into the tree, # so a path below it names nothing, the site about page included. test_expect_success 'a path below the about page answers 404' ' -- cgit 2.12.1